|
364 | 364 | * @type Boolean
|
365 | 365 | */
|
366 | 366 | try {
|
367 |
| - support.nodeClass = !(toString.call(document) == objectClass && !String({ 'toString': 0 })); |
| 367 | + support.nodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + '')); |
368 | 368 | } catch(e) {
|
369 | 369 | support.nodeClass = true;
|
370 | 370 | }
|
|
510 | 510 | ' <%= loop %>;' +
|
511 | 511 | ' <% if (support.enumPrototypes || useHas) { %>\n }<% } %>\n' +
|
512 | 512 | ' }' +
|
513 |
| - ' <% } %>' + |
514 | 513 |
|
515 | 514 | // Because IE < 9 can't set the `[[Enumerable]]` attribute of an
|
516 | 515 | // existing property and the `constructor` property of a prototype
|
517 | 516 | // defaults to non-enumerable, Lo-Dash skips the `constructor`
|
518 | 517 | // property when it infers it's iterating over a `prototype` object.
|
519 |
| - ' <% if (support.nonEnumShadows) { %>\n\n' + |
| 518 | + ' <% if (support.nonEnumShadows) { %>\n\n' + |
520 | 519 | ' var ctor = iterable.constructor;\n' +
|
521 |
| - ' <% for (var k = 0; k < 7; k++) { %>\n' + |
| 520 | + ' <% for (var k = 0; k < 7; k++) { %>\n' + |
522 | 521 | " index = '<%= shadowedProps[k] %>';\n" +
|
523 | 522 | ' if (<%' +
|
524 | 523 | " if (shadowedProps[k] == 'constructor') {" +
|
525 | 524 | ' %>!(ctor && ctor.prototype === iterable) && <%' +
|
526 | 525 | ' } %>hasOwnProperty.call(iterable, index)) {\n' +
|
527 | 526 | ' <%= loop %>\n' +
|
528 | 527 | ' }' +
|
| 528 | + ' <% } %>' + |
529 | 529 | ' <% } %>' +
|
530 | 530 | ' <% } %>' +
|
531 | 531 | ' <% if (arrays || support.nonEnumArgs) { %>\n}<% } %>\n' +
|
|
753 | 753 | );
|
754 | 754 | }
|
755 | 755 |
|
756 |
| - /** |
757 |
| - * A function compiled to iterate `arguments` objects, arrays, objects, and |
758 |
| - * strings consistenly across environments, executing the `callback` for each |
759 |
| - * element in the `collection`. The `callback` is bound to `thisArg` and invoked |
760 |
| - * with three arguments; (value, index|key, collection). Callbacks may exit |
761 |
| - * iteration early by explicitly returning `false`. |
762 |
| - * |
763 |
| - * @private |
764 |
| - * @type Function |
765 |
| - * @param {Array|Object|String} collection The collection to iterate over. |
766 |
| - * @param {Function} [callback=identity] The function called per iteration. |
767 |
| - * @param {Mixed} [thisArg] The `this` binding of `callback`. |
768 |
| - * @returns {Array|Object|String} Returns `collection`. |
769 |
| - */ |
770 |
| - var each = createIterator(eachIteratorOptions); |
771 |
| - |
772 | 756 | /**
|
773 | 757 | * Used by `template` to escape characters for inclusion in compiled
|
774 | 758 | * string literals.
|
|
802 | 786 | function isNode(value) {
|
803 | 787 | // IE < 9 presents DOM nodes as `Object` objects except they have `toString`
|
804 | 788 | // methods that are `typeof` "string" and still can coerce nodes to strings
|
805 |
| - return typeof value.toString != 'function' && typeof String(value) == 'string'; |
| 789 | + return typeof value.toString != 'function' && typeof (value + '') == 'string'; |
806 | 790 | }
|
807 | 791 |
|
808 | 792 | /**
|
|
845 | 829 | }
|
846 | 830 | // check that the constructor is `Object` (i.e. `Object instanceof Object`)
|
847 | 831 | var ctor = value.constructor;
|
848 |
| - if ((!isFunction(ctor) && (support.nodeClass || !isNode(value))) || ctor instanceof ctor) { |
| 832 | + |
| 833 | + if (isFunction(ctor) ? ctor instanceof ctor : (support.nodeClass || !isNode(value))) { |
849 | 834 | // IE < 9 iterates inherited properties before own properties. If the first
|
850 | 835 | // iterated property is an object's own property then there are no inherited
|
851 | 836 | // enumerable properties.
|
|
867 | 852 | return result; |
868 | 853 | }
|
869 | 854 |
|
870 |
| - /** |
871 |
| - * A fallback implementation of `Object.keys` that produces an array of the |
872 |
| - * given object's own enumerable property names. |
873 |
| - * |
874 |
| - * @private |
875 |
| - * @type Function |
876 |
| - * @param {Object} object The object to inspect. |
877 |
| - * @returns {Array} Returns a new array of property names. |
878 |
| - */ |
879 |
| - var shimKeys = createIterator({ |
880 |
| - 'args': 'object', |
881 |
| - 'init': '[]', |
882 |
| - 'top': 'if (!(objectTypes[typeof object])) return result', |
883 |
| - 'loop': 'result.push(index)', |
884 |
| - 'arrays': false |
885 |
| - }); |
886 |
| - |
887 | 855 | /**
|
888 | 856 | * Slices the `collection` from the `start` index up to, but not including,
|
889 | 857 | * the `end` index.
|
|
973 | 941 | return (support.argsObject && value instanceof Array) || toString.call(value) == arrayClass;
|
974 | 942 | };
|
975 | 943 |
|
| 944 | + /** |
| 945 | + * A fallback implementation of `Object.keys` that produces an array of the |
| 946 | + * given object's own enumerable property names. |
| 947 | + * |
| 948 | + * @private |
| 949 | + * @type Function |
| 950 | + * @param {Object} object The object to inspect. |
| 951 | + * @returns {Array} Returns a new array of property names. |
| 952 | + */ |
| 953 | + var shimKeys = createIterator({ |
| 954 | + 'args': 'object', |
| 955 | + 'init': '[]', |
| 956 | + 'top': 'if (!(objectTypes[typeof object])) return result', |
| 957 | + 'loop': 'result.push(index)', |
| 958 | + 'arrays': false |
| 959 | + }); |
| 960 | + |
976 | 961 | /**
|
977 | 962 | * Creates an array composed of the own enumerable property names of `object`.
|
978 | 963 | *
|
|
997 | 982 | return nativeKeys(object);
|
998 | 983 | };
|
999 | 984 |
|
| 985 | + /** |
| 986 | + * A function compiled to iterate `arguments` objects, arrays, objects, and |
| 987 | + * strings consistenly across environments, executing the `callback` for each |
| 988 | + * element in the `collection`. The `callback` is bound to `thisArg` and invoked |
| 989 | + * with three arguments; (value, index|key, collection). Callbacks may exit |
| 990 | + * iteration early by explicitly returning `false`. |
| 991 | + * |
| 992 | + * @private |
| 993 | + * @type Function |
| 994 | + * @param {Array|Object|String} collection The collection to iterate over. |
| 995 | + * @param {Function} [callback=identity] The function called per iteration. |
| 996 | + * @param {Mixed} [thisArg] The `this` binding of `callback`. |
| 997 | + * @returns {Array|Object|String} Returns `collection`. |
| 998 | + */ |
| 999 | + var each = createIterator(eachIteratorOptions); |
| 1000 | + |
1000 | 1001 | /**
|
1001 | 1002 | * Used to convert characters to HTML entities:
|
1002 | 1003 | *
|
|
0 commit comments