nodeType: Node.ELEMENT_NODE,
setData: function(key, value) {
- if(value !== undefined) {
- this._$.data(key, value);
+ if(arguments.length === 2) {
+ if(_.isUndefined(value)) {
+ this._$.removeData(key);
+ } else {
+ this._$.data(key, value);
+ }
} else {
this._$.removeData(_.keys(this._$.data()));
this._$.data(key);
node.setData({key1: 'value1', key2: 'value2'});
expect(node.getData()).to.eql({key1: 'value1', key2: 'value2'});
});
+
+ it('can remove specific data', function() {
+ node.setData('key', 'value');
+ node.setData('key', undefined);
+ expect(node.getData('key')).to.be.undefined;
+ });
});
describe('Changing node tag', function() {