\r
'use strict';\r
\r
+\r
+var tagSelector = '[wlxml-tag]';\r
+\r
var CanvasNode = function(desc) {\r
if(desc instanceof $) {\r
this.dom = desc;\r
}\r
\r
CanvasNode.prototype.isSame = function(other) {\r
- return this.dom.get(0).isSameNode(other.dom.get(0));\r
+ return (other instanceof CanvasNode) && this.dom.get(0).isSameNode(other.dom.get(0));\r
+}\r
+\r
+CanvasNode.prototype.children = function() {\r
+ var list = [];\r
+ this.dom.children(tagSelector).each(function() {\r
+ list.push(new CanvasNode($(this)));\r
+ });\r
+ return $(list);\r
+};\r
+\r
+\r
+CanvasNode.prototype.parent = function() {\r
+ var node = this.dom.parent(tagSelector);\r
+ if(node.length)\r
+ return new CanvasNode(node);\r
+ return null;\r
+};\r
+\r
+CanvasNode.prototype.parents = function() {\r
+ var list = [];\r
+ this.dom.parents(tagSelector).each(function() {\r
+ list.push(new CanvasNode($(this)));\r
+ });\r
+ return $(list);\r
+};\r
+\r
+\r
+CanvasNode.prototype.isOfClass = function(klass) {\r
+ return this.getClass() && this.getClass().substr(0, klass.length) === klass;\r
}\r
\r
return {\r