~ted/lazr-js/annoying-debug-message

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/dom/selector-debug.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-09-09 14:20:30 UTC
  • mfrom: (182.1.3 yui-3.2)
  • Revision ID: launchpad@pqm.canonical.com-20100909142030-13w6vo0ixfysxc15
[r=beuno] Update lazr-js to yui-3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.1.2
6
 
build: 56
 
5
version: 3.2.0
 
6
build: 2676
7
7
*/
8
8
YUI.add('selector-native', function(Y) {
9
9
 
32
32
 
33
33
    useNative: true,
34
34
 
35
 
    _compare: ('sourceIndex' in document.documentElement) ?
 
35
    _compare: ('sourceIndex' in Y.config.doc.documentElement) ?
36
36
        function(nodeA, nodeB) {
37
37
            var a = nodeA.sourceIndex,
38
38
                b = nodeB.sourceIndex;
45
45
 
46
46
            return -1;
47
47
 
48
 
        } : (document.documentElement[COMPARE_DOCUMENT_POSITION] ?
 
48
        } : (Y.config.doc.documentElement[COMPARE_DOCUMENT_POSITION] ?
49
49
        function(nodeA, nodeB) {
50
50
            if (nodeA[COMPARE_DOCUMENT_POSITION](nodeB) & 4) {
51
51
                return -1;
110
110
    query: function(selector, root, firstOnly, skipNative) {
111
111
        root = root || Y.config.doc;
112
112
        var ret = [],
113
 
            useNative = (Y.Selector.useNative && document.querySelector && !skipNative),
 
113
            useNative = (Y.Selector.useNative && Y.config.doc.querySelector && !skipNative),
114
114
            queries = [[selector, root]],
115
115
            query,
116
116
            result,
169
169
    },
170
170
 
171
171
    _nativeQuery: function(selector, root, one) {
 
172
        if (Y.UA.webkit && selector.indexOf(':checked') > -1 &&
 
173
                (Y.Selector.pseudos && Y.Selector.pseudos.checked)) { // webkit (chrome, safari) fails to find "selected"
 
174
            return Y.Selector.query(selector, root, one, true); // redo with skipNative true to try brute query
 
175
        }
172
176
        try {
173
177
            //Y.log('trying native query with: ' + selector, 'info', 'selector-native');
174
178
            return root['querySelector' + (one ? '' : 'All')](selector);
269
273
})(Y);
270
274
 
271
275
 
272
 
}, '3.1.2' ,{requires:['dom-base']});
 
276
}, '3.2.0' ,{requires:['dom-base']});
273
277
YUI.add('selector-css2', function(Y) {
274
278
 
275
279
/**
360
364
                tokens = Selector._tokenize(selector),
361
365
                token = tokens[tokens.length - 1],
362
366
                rootDoc = Y.DOM._getDoc(root),
 
367
                child,
363
368
                id,
364
369
                className,
365
370
                tagName;
380
385
                className = token.className;
381
386
                tagName = token.tagName || '*';
382
387
 
383
 
                // try ID first
384
 
                if (id) {
385
 
                    nodes = Y.DOM.allById(id, root);
386
 
                // try className
387
 
                } else if (className) {
388
 
                    nodes = root.getElementsByClassName(className);
389
 
                } else { // default to tagName
390
 
                    nodes = root.getElementsByTagName(tagName);
 
388
                if (root.getElementsByTagName) { // non-IE lacks DOM api on doc frags
 
389
                    // try ID first, unless no root.all && root not in document
 
390
                    // (root.all works off document, but not getElementById)
 
391
                    // TODO: move to allById?
 
392
                    if (id && (root.all || (root.nodeType === 9 || Y.DOM.inDoc(root)))) {
 
393
                        nodes = Y.DOM.allById(id, root);
 
394
                    // try className
 
395
                    } else if (className) {
 
396
                        nodes = root.getElementsByClassName(className);
 
397
                    } else { // default to tagName
 
398
                        nodes = root.getElementsByTagName(tagName);
 
399
                    }
 
400
 
 
401
                } else { // brute getElementsByTagName('*')
 
402
                    child = root.firstChild;
 
403
                    while (child) {
 
404
                        if (child.tagName) { // only collect HTMLElements
 
405
                            nodes.push(child);
 
406
                        }
 
407
                        child = child.nextSilbing || child.firstChild;
 
408
                    }
391
409
                }
392
 
 
393
410
                if (nodes.length) {
394
411
                    ret = Selector._filterNodes(nodes, tokens, firstOnly);
395
412
                }
443
460
                            if ((operator === '=' && value !== test[2]) ||  // fast path for equality
444
461
                                (typeof operator !== 'string' && // protect against String.test monkey-patch (Moo)
445
462
                                operator.test && !operator.test(value)) ||  // regex test
446
 
                                (typeof operator === 'function' && !operator(tmpNode, test[0]))) { // function test
 
463
                                (!operator.test && // protect against RegExp as function (webkit)
 
464
                                        typeof operator === 'function' && !operator(tmpNode, test[0]))) { // function test
447
465
 
448
466
                                // skip non element nodes or non-matching tags
449
467
                                if ((tmpNode = tmpNode[path])) {
516
534
                    // add prefiltering for ID and CLASS
517
535
                    if ((match[1] === 'id' && operator === '=') ||
518
536
                            (match[1] === 'className' &&
519
 
                            document.documentElement.getElementsByClassName &&
 
537
                            Y.config.doc.documentElement.getElementsByClassName &&
520
538
                            (operator === '~=' || operator === '='))) {
521
539
                        token.prefilter = match[1];
522
540
                        token[match[1]] = match[3];
699
717
Y.Selector.getters.src = Y.Selector.getters.rel = Y.Selector.getters.href;
700
718
 
701
719
// IE wants class with native queries
702
 
if (Y.Selector.useNative && document.querySelector) {
 
720
if (Y.Selector.useNative && Y.config.doc.querySelector) {
703
721
    Y.Selector.shorthand['\\.(-?[_a-z]+[-\\w]*)'] = '[class~=$1]';
704
722
}
705
723
 
706
724
 
707
725
 
708
 
}, '3.1.2' ,{requires:['selector-native']});
709
 
 
710
 
 
711
 
YUI.add('selector', function(Y){}, '3.1.2' ,{use:['selector-native', 'selector-css2']});
 
726
}, '3.2.0' ,{requires:['selector-native']});
 
727
 
 
728
 
 
729
YUI.add('selector', function(Y){}, '3.2.0' ,{use:['selector-native', 'selector-css2']});
712
730