+ setTag: function(tagName) {
+ var node = this.document.createElementNode({tagName: tagName}),
+ oldTagName = this.getTagName(),
+ myContents = this._$.contents();
+
+ this.getAttrs().forEach(function(attribute) {
+ node.setAttr(attribute.name, attribute.value, true);
+ });
+ node.setData(this.getData());
+
+ if(this.sameNode(this.document.root)) {
+ defineDocumentProperties(this.document, node._$);
+ }
+ this._$.replaceWith(node._$);
+ this._setNativeNode(node._$[0]);
+ this._$.append(myContents);
+ this.triggerChangeEvent('nodeTagChange', {oldTagName: oldTagName, newTagName: this.getTagName()});
+ },
+
+ getAttr: function(name) {
+ return this._$.attr(name);
+ },
+
+ setAttr: function(name, value, silent) {
+ var oldVal = this.getAttr(name);
+ this._$.attr(name, value);
+ if(!silent) {
+ this.triggerChangeEvent('nodeAttrChange', {attr: name, oldVal: oldVal, newVal: value});
+ }
+ },
+
+ getAttrs: function() {
+ var toret = [];
+ for(var i = 0; i < this.nativeNode.attributes.length; i++) {
+ toret.push(this.nativeNode.attributes[i]);
+ }
+ return toret;
+ },
+
+ append: function(documentNode) {
+ this._$.append(documentNode.nativeNode);