Changeset 7410

Show
Ignore:
Timestamp:
02/22/07 20:41:19 (23 months ago)
Author:
alex
Message:

ensure that NodeList? implements JS 1.6 methods on IE. Makes test pages work correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/NodeList.js

    r7392 r7410  
    124124                                var ret = new dojo.NodeList(); 
    125125                                this.forEach(function(item){ 
    126                                         dojo.query(queryStr, item).forEach(ret.push, ret); 
     126                                        dojo.query(queryStr, item).forEach(function(subItem){ 
     127                                                if(typeof subItem != "undefined"){ 
     128                                                        ret.push(subItem); 
     129                                                } 
     130                                        }); 
    127131                                }); 
    128132                                return ret; 
     
    136140                                // filtering function objects. 
    137141 
    138                                 // simpleQuery may be a CSS class, ID, attribute, or pseudo 
    139                                 // selector that further filters the contents of this NodeList. 
    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); 
     142                                var items = this; 
     143                                if(typeof arguments[0] == "string"){ 
     144                                        items = dojo._filterQueryResult(this, arguments[0]); 
     145                                        if(arguments.length == 1){ 
     146                                                return items; 
    146147                                        } 
    147                                 }); 
    148                                 return orphans; 
    149                                 */ 
     148                                } 
     149                                return dojo.lang.filter(items, arguments[1], arguments[2]); 
    150150                        }, 
    151151 
     
    168168        //              http://www.hedgerwow.com/360/dhtml/js-array2.html 
    169169        if(h.ie){ 
     170                var dl = d.lang; 
     171                // make sure that it has all the JS 1.6 things we need before we subclass 
     172                dl.extend(dojo.NodeList, 
     173                        { 
     174                                // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array#Methods 
     175                                // must implement the following JS 1.6 methods: 
     176 
     177                                // fixme: we can't use hitch here as it binds to an object, 
     178                                // which we don't want. Time for a real partial() ? 
     179                                forEach: function(callback, thisObj){ 
     180                                        return dl.forEach(this, callback, thisObj); 
     181                                }, 
     182 
     183                                every: function(callback, thisObj){ 
     184                                        return dl.every(this, callback, thisObj); 
     185                                }, 
     186 
     187                                some: function(callback, thisObj){ 
     188                                        return dl.some(this, callback, thisObj); 
     189                                }, 
     190 
     191                                map: function(obj, unary_func){ 
     192                                        return dl.map(this, obj, unary_func); 
     193                                } 
     194 
     195                                // NOTE: filter() is handled in NodeList by default 
     196                        } 
     197                ); 
     198 
     199 
     200 
    170201                var subClassStr = function(className){ 
    171202                        return ( 
     
    182213                var popup = window.createPopup() 
    183214                popup.document.write("<script>"+scs+"</script>"); 
     215                // our fix to ensure that we don't hit strange scoping/timing issues 
     216                // insisde of setTimeout() blocks 
    184217                popup.show(1, 1, 1, 1); 
     218 
    185219        } 
    186220        // look, ma, it's synchronous!