fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make sure to run all tests
[fnpeditor.git]
/
src
/
smartxml
/
smartxml.js
diff --git
a/src/smartxml/smartxml.js
b/src/smartxml/smartxml.js
index
2d0e09f
..
43e3041
100644
(file)
--- a/
src/smartxml/smartxml.js
+++ b/
src/smartxml/smartxml.js
@@
-29,7
+29,21
@@
$.extend(DocumentNode.prototype, {
sameNode: function(otherNode) {
return this.nativeNode === otherNode.nativeNode;
sameNode: function(otherNode) {
return this.nativeNode === otherNode.nativeNode;
- }
+ },
+
+ parent: function() {
+ return this.nativeNode.parentNode ? new ElementNode(this.nativeNode.parentNode) : null;
+ },
+
+ before: function(node) {
+ this._$.before(node.nativeNode);
+ },
+
+ wrapWith: function(node) {
+ if(this.parent())
+ this.before(node);
+ node.append(this);
+ },
});
var ElementNode = function(nativeNode) {
});
var ElementNode = function(nativeNode) {
@@
-43,14
+57,6
@@
$.extend(ElementNode.prototype, DocumentNode.prototype, {
return this.nativeNode.tagName.toLowerCase();
},
return this.nativeNode.tagName.toLowerCase();
},
- append: function(documentNode) {
- this._$.append(documentNode.nativeNode);
- },
-
- before: function(node) {
- this._$.before(node.nativeNode);
- },
-
contents: function() {
var toret = [];
this._$.contents().each(function() {
contents: function() {
var toret = [];
this._$.contents().each(function() {
@@
-66,8
+72,16
@@
$.extend(ElementNode.prototype, DocumentNode.prototype, {
return this._$.contents().index(node._$);
},
return this._$.contents().index(node._$);
},
- parent: function() {
- return new ElementNode(this._$.parent());
+ getAttr: function(name) {
+ return this._$.attr(name);
+ },
+
+ setAttr: function(name, value) {
+ this._$.attr(name, value);
+ },
+
+ append: function(documentNode) {
+ this._$.append(documentNode.nativeNode);
},
unwrapContent: function() {
},
unwrapContent: function() {