From b2e6eff88e29de706181587f619e0e4b125a5c56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 14 Mar 2014 13:00:13 +0100 Subject: [PATCH 1/1] wlxml: ElementNode.getClassHierarchy --- src/wlxml/wlxml.js | 6 +++++- src/wlxml/wlxml.test.js | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wlxml/wlxml.js b/src/wlxml/wlxml.js index 5194c19..0505116 100644 --- a/src/wlxml/wlxml.js +++ b/src/wlxml/wlxml.js @@ -72,6 +72,9 @@ $.extend(WLXMLElementNode.prototype, WLXMLDocumentNodeMethods, smartxml.ElementN getClass: function() { return this.getAttr('class') || ''; }, + getClassHierarchy: function() { + return getClassLists(this.getClass()); + }, setClass: function(klass) { if(klass !== this.klass) { installObject(this, klass); @@ -384,7 +387,8 @@ return { return this.WLXMLDocumentFromXML(xml).root; }, - WLXMLDocument: WLXMLDocument + WLXMLDocument: WLXMLDocument, + getClassHierarchy: getClassLists }; }); \ No newline at end of file diff --git a/src/wlxml/wlxml.test.js b/src/wlxml/wlxml.test.js index c37b21f..9904154 100644 --- a/src/wlxml/wlxml.test.js +++ b/src/wlxml/wlxml.test.js @@ -27,6 +27,11 @@ describe('WLXMLDocument', function() { expect(node.getClass()).to.equal('class.subclass'); }); + it('returns its class hierarchy', function() { + var node = nodeFromXML('
'); + expect(node.getClassHierarchy()).to.eql(['', 'a', 'a.b', 'a.b.c']); + }); + it('returns unregistered attributes', function() { var testClasses = { 'testClass': { -- 2.20.1