X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/be657bf05cf1a986983b7e5583f32db116f9ebe9..7e4209de3c2972b1ca4ada5e3de85197365f58af:/src/smartxml/smartxml.test.js diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 3175ae9..08598aa 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -769,7 +769,9 @@ describe('smartxml', function() { c = b.contents()[0]; var parents = c.parents(); - expect(parents).to.eql([b,a]); + // @@ + expect(parents[0].sameNode(b)).to.be.true; + expect(parents[1].sameNode(a)).to.be.true; }); }); @@ -939,6 +941,57 @@ describe('smartxml', function() { expect(textNode.textTestTransformation().sameNode(textNode)).to.be.true; expect(textNode.elementTestTransfomation).to.be.undefined; }); + + it('allows text/element node methods and transformations to access node and transormations on document node', function() { + + var doc = getDocumentFromXML('
text
'); + + doc.registerExtension({ + documentNode: { + methods: { + test: function() { + return 'super'; + } + }, + transformations: { + testT: function() { + return 'super_trans'; + } + } + }, + elementNode: { + methods: { + test: function() { + return 'element_sub_' + this.__super__.test(); + } + }, + transformations: { + testT: function() { + return 'element_trans_sub_' + this.__super__.testT(); + } + } + }, + textNode: { + methods: { + test: function() { + return 'text_sub_' + this.__super__.test(); + } + }, + transformations: { + testT: function() { + return 'text_trans_sub_' + this.__super__.testT(); + } + } + } + }); + + var textNode = doc.root.contents()[0]; + + expect(doc.root.test()).to.equal('element_sub_super'); + expect(textNode.test()).to.equal('text_sub_super'); + expect(doc.root.testT()).to.equal('element_trans_sub_super_trans'); + expect(textNode.testT()).to.equal('text_trans_sub_super_trans'); + }); }); // describe('Undo/redo', function() {