Changeset 7392
- Timestamp:
- 02/21/07 08:37:57 (23 months ago)
- Files:
-
- 1 modified
-
trunk/src/NodeList.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/NodeList.js
r7352 r7392 1 1 dojo.provide("dojo.NodeList"); 2 2 dojo.require("dojo.lang.*"); 3 dojo.require("dojo.dom"); 3 4 dojo.require("dojo.experimental"); 4 5 dojo.experimental("dojo.NodeList"); … … 43 44 box: (h.ie) ? function(){ 44 45 // returns a box object for the first element in a node list 46 dojo.debug("dojo.NodeList.box is unimplemented"); 45 47 } : function(){ 48 dojo.debug("dojo.NodeList.box is unimplemented"); 46 49 }, 47 50 … … 49 52 // returns the box objects all elements in a node list as an 50 53 // Array 54 dojo.debug("dojo.NodeList.boxes is unimplemented"); 51 55 }, 52 56 … … 71 75 // "after" 72 76 // or an offset in the childNodes property 73 }, 74 75 orphan: function(filter){ 76 // removes elements in this list that match filter from their 77 // parents and returns them as a new NodeList. 77 var item = dojo.query(queryOrNode)[0]; 78 position = position||"last"; 79 80 for(var x=0; x<this.length; x++){ 81 dojo.dom.insertAtPosition(this[x], item, position); 82 } 83 }, 84 85 orphan: function(simpleFilter){ 86 // removes elements in this list that match the simple filter 87 // from their parents and returns them as a new NodeList. 88 var orphans = dojo._filterQueryResult(this, simpleFilter); 89 orphans.forEach(function(item){ 90 if(item["parentNode"]){ 91 item.parentNode.removeChild(item); 92 } 93 }); 94 return orphans; 78 95 }, 79 96 … … 88 105 // "after" 89 106 // or an offset in the childNodes property 107 var item = this[0]; 108 position = position||"last"; 109 var adoptees = dojo.query(queryOrListOrNode); 110 111 for(var x=0; x<adoptees.length; x++){ 112 dojo.dom.insertAtPosition(adoptees[x], item, position); 113 } 90 114 }, 91 115 … … 96 120 // the passed query but use elements of the current NodeList as 97 121 // query roots. 122 123 // FIXME: probably slow 124 var ret = new dojo.NodeList(); 125 this.forEach(function(item){ 126 dojo.query(queryStr, item).forEach(ret.push, ret); 127 }); 128 return ret; 98 129 }, 99 130 100 131 filter: function(simpleQuery){ 132 // (callback, [thisObject]) 133 // (simpleQuery, callback, [thisObject]) 101 134 // "masks" the built-in javascript filter() method to support 102 135 // passing a simple string filter in addition to supporting … … 106 139 // selector that further filters the contents of this NodeList. 107 140 // A new NodeList with the resulting elements is returned. 141 /* 142 var orphans = dojo._filterQueryResult(this, simpleFilter); 143 orphans.forEach(function(item){ 144 if(item["parentNode"]){ 145 item.parentNode.removeChild(item); 146 } 147 }); 148 return orphans; 149 */ 108 150 }, 109 151