Permalink
Browse files

build dom

  • Loading branch information...
1 parent 0e7a75d commit d5590ce9ed224fd513700a9a538494aaa064b603 @msweeney msweeney committed Nov 17, 2011
@@ -484,6 +484,42 @@ Y.mix(Y.DOM, {
}
return ret;
+ },
+
+ wrap: function(node, html) {
+ var parent = Y.DOM.create(html),
+ nodes = parent.getElementsByTagName('*');
+
+ if (nodes.length) {
+ parent = nodes[nodes.length - 1];
+ }
+
+ if (node.parentNode) {
+ node.parentNode.replaceChild(parent, node);
+ }
+ parent.appendChild(node);
+ },
+
+ unwrap: function(node) {
+ var parent = node.parentNode,
+ lastChild = parent.lastChild,
+ next = node,
+ grandparent;
+
+ if (parent) {
+ grandparent = parent.parentNode;
+ if (grandparent) {
+ node = parent.firstChild;
+ while (node !== lastChild) {
+ next = node.nextSibling;
+ grandparent.insertBefore(node, parent);
+ node = next;
+ }
+ grandparent.replaceChild(lastChild, parent);
+ } else {
+ parent.removeChild(node);
+ }
+ }
}
});

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -479,6 +479,42 @@ Y.mix(Y.DOM, {
}
return ret;
+ },
+
+ wrap: function(node, html) {
+ var parent = Y.DOM.create(html),
+ nodes = parent.getElementsByTagName('*');
+
+ if (nodes.length) {
+ parent = nodes[nodes.length - 1];
+ }
+
+ if (node.parentNode) {
+ node.parentNode.replaceChild(parent, node);
+ }
+ parent.appendChild(node);
+ },
+
+ unwrap: function(node) {
+ var parent = node.parentNode,
+ lastChild = parent.lastChild,
+ next = node,
+ grandparent;
+
+ if (parent) {
+ grandparent = parent.parentNode;
+ if (grandparent) {
+ node = parent.firstChild;
+ while (node !== lastChild) {
+ next = node.nextSibling;
+ grandparent.insertBefore(node, parent);
+ node = next;
+ }
+ grandparent.replaceChild(lastChild, parent);
+ } else {
+ parent.removeChild(node);
+ }
+ }
}
});
@@ -332,42 +332,6 @@ Y_DOM = {
return (typeof ret !== 'undefined') ? ret : nodes;
},
- wrap: function(node, html) {
- var parent = Y.DOM.create(html),
- nodes = parent.getElementsByTagName('*');
-
- if (nodes.length) {
- parent = nodes[nodes.length - 1];
- }
-
- if (node.parentNode) {
- node.parentNode.replaceChild(parent, node);
- }
- parent.appendChild(node);
- },
-
- unwrap: function(node) {
- var parent = node.parentNode,
- lastChild = parent.lastChild,
- next = node,
- grandparent;
-
- if (parent) {
- grandparent = parent.parentNode;
- if (grandparent) {
- node = parent.firstChild;
- while (node !== lastChild) {
- next = node.nextSibling;
- grandparent.insertBefore(node, parent);
- node = next;
- }
- grandparent.replaceChild(lastChild, parent);
- } else {
- parent.removeChild(node);
- }
- }
- },
-
generateID: function(el) {
var id = el.id;
Oops, something went wrong.

0 comments on commit d5590ce

Please sign in to comment.