Changeset 7392

Show
Ignore:
Timestamp:
02/21/07 08:37:57 (23 months ago)
Author:
alex
Message:

starting to actually fill in NodeList?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/NodeList.js

    r7352 r7392  
    11dojo.provide("dojo.NodeList"); 
    22dojo.require("dojo.lang.*"); 
     3dojo.require("dojo.dom"); 
    34dojo.require("dojo.experimental"); 
    45dojo.experimental("dojo.NodeList"); 
     
    4344                        box: (h.ie) ? function(){ 
    4445                                // returns a box object for the first element in a node list 
     46                                dojo.debug("dojo.NodeList.box is unimplemented"); 
    4547                        } : function(){ 
     48                                dojo.debug("dojo.NodeList.box is unimplemented"); 
    4649                        }, 
    4750 
     
    4952                                // returns the box objects all elements in a node list as an 
    5053                                // Array 
     54                                dojo.debug("dojo.NodeList.boxes is unimplemented"); 
    5155                        }, 
    5256 
     
    7175                                //              "after" 
    7276                                // 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; 
    7895                        }, 
    7996 
     
    88105                                //              "after" 
    89106                                // 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                                } 
    90114                        }, 
    91115 
     
    96120                                // the passed query but use elements of the current NodeList as 
    97121                                // 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; 
    98129                        }, 
    99130 
    100131                        filter: function(simpleQuery){ 
     132                                //                      (callback, [thisObject]) 
     133                                //                      (simpleQuery, callback, [thisObject]) 
    101134                                // "masks" the built-in javascript filter() method to support 
    102135                                // passing a simple string filter in addition to supporting 
     
    106139                                // selector that further filters the contents of this NodeList. 
    107140                                // 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                                */ 
    108150                        }, 
    109151