fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
smartxml: Improving get/set data api
[fnpeditor.git]
/
src
/
smartxml
/
smartxml.js
diff --git
a/src/smartxml/smartxml.js
b/src/smartxml/smartxml.js
index
034b907
..
1876076
100644
(file)
--- a/
src/smartxml/smartxml.js
+++ b/
src/smartxml/smartxml.js
@@
-1,8
+1,9
@@
define([
'libs/jquery',
define([
'libs/jquery',
+ 'libs/underscore',
'libs/backbone',
'smartxml/events'
'libs/backbone',
'smartxml/events'
-], function($, Backbone, events) {
+], function($,
_,
Backbone, events) {
'use strict';
'use strict';
@@
-55,10
+56,19
@@
$.extend(ElementNode.prototype, DocumentNode.prototype, {
nodeType: Node.ELEMENT_NODE,
setData: function(key, value) {
nodeType: Node.ELEMENT_NODE,
setData: function(key, value) {
- this._$.data(key, value);
+ if(value !== undefined) {
+ this._$.data(key, value);
+ } else {
+ this._$.removeData(_.keys(this._$.data()));
+ this._$.data(key);
+ }
},
},
+
getData: function(key) {
getData: function(key) {
- return this._$.data(key);
+ if(key) {
+ return this._$.data(key);
+ }
+ return this._$.data();
},
getTagName: function() {
},
getTagName: function() {