|
798 | 798 | return htmlEscapes[match];
|
799 | 799 | }
|
800 | 800 |
|
801 |
| - /** |
802 |
| - * Checks if a given `value` is an object created by the `Object` constructor |
803 |
| - * assuming objects created by the `Object` constructor have no inherited |
804 |
| - * enumerable properties and that there are no `Object.prototype` extensions. |
805 |
| - * |
806 |
| - * @private |
807 |
| - * @param {Mixed} value The value to check. |
808 |
| - * @param {Boolean} [skipArgsCheck=false] Internally used to skip checks for |
809 |
| - * `arguments` objects. |
810 |
| - * @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, |
811 |
| - * else `false`. |
812 |
| - */ |
813 |
| - function isPlainObject(value, skipArgsCheck) { |
814 |
| - // avoid non-objects and false positives for `arguments` objects |
815 |
| - var result = false; |
816 |
| - if (!(value && typeof value == 'object') || (!skipArgsCheck && isArguments(value))) { |
817 |
| - return result; |
818 |
| - } |
819 |
| - // IE < 9 presents DOM nodes as `Object` objects except they have `toString` |
820 |
| - // methods that are `typeof` "string" and still can coerce nodes to strings. |
821 |
| - // Also check that the constructor is `Object` (i.e. `Object instanceof Object`) |
822 |
| - var ctor = value.constructor; |
823 |
| - if ((!noNodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) && |
824 |
| - (!isFunction(ctor) || ctor instanceof ctor)) { |
825 |
| - // IE < 9 iterates inherited properties before own properties. If the first |
826 |
| - // iterated property is an object's own property then there are no inherited |
827 |
| - // enumerable properties. |
828 |
| - if (iteratesOwnLast) { |
829 |
| - forIn(value, function(objValue, objKey) { |
830 |
| - result = !hasOwnProperty.call(value, objKey); |
831 |
| - return false; |
832 |
| - }); |
833 |
| - return result === false; |
834 |
| - } |
835 |
| - // In most environments an object's own properties are iterated before |
836 |
| - // its inherited properties. If the last iterated property is an object's |
837 |
| - // own property then there are no inherited enumerable properties. |
838 |
| - forIn(value, function(objValue, objKey) { |
839 |
| - result = objKey; |
840 |
| - }); |
841 |
| - return result === false || hasOwnProperty.call(value, result); |
842 |
| - } |
843 |
| - return result; |
844 |
| - } |
845 |
| - |
846 | 801 | /**
|
847 | 802 | * Creates a new function that, when called, invokes `func` with the `this`
|
848 | 803 | * binding of `thisArg` and the arguments (value, index, object).
|
|
1005 | 960 | };
|
1006 | 961 | }
|
1007 | 962 |
|
| 963 | + /** |
| 964 | + * Checks if a given `value` is an object created by the `Object` constructor |
| 965 | + * assuming objects created by the `Object` constructor have no inherited |
| 966 | + * enumerable properties and that there are no `Object.prototype` extensions. |
| 967 | + * |
| 968 | + * @private |
| 969 | + * @param {Mixed} value The value to check. |
| 970 | + * @param {Boolean} [skipArgsCheck=false] Internally used to skip checks for |
| 971 | + * `arguments` objects. |
| 972 | + * @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, |
| 973 | + * else `false`. |
| 974 | + */ |
| 975 | + function isPlainObject(value, skipArgsCheck) { |
| 976 | + return value |
| 977 | + ? value == ObjectProto || (value.__proto__ == ObjectProto && (skipArgsCheck || !isArguments(value))) |
| 978 | + : false; |
| 979 | + } |
| 980 | + // fallback for IE |
| 981 | + if (!isPlainObject(objectTypes)) { |
| 982 | + isPlainObject = function(value, skipArgsCheck) { |
| 983 | + // avoid non-objects and false positives for `arguments` objects |
| 984 | + var result = false; |
| 985 | + if (!(value && typeof value == 'object') || (!skipArgsCheck && isArguments(value))) { |
| 986 | + return result; |
| 987 | + } |
| 988 | + // IE < 9 presents DOM nodes as `Object` objects except they have `toString` |
| 989 | + // methods that are `typeof` "string" and still can coerce nodes to strings. |
| 990 | + // Also check that the constructor is `Object` (i.e. `Object instanceof Object`) |
| 991 | + var ctor = value.constructor; |
| 992 | + if ((!noNodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) && |
| 993 | + (!isFunction(ctor) || ctor instanceof ctor)) { |
| 994 | + // IE < 9 iterates inherited properties before own properties. If the first |
| 995 | + // iterated property is an object's own property then there are no inherited |
| 996 | + // enumerable properties. |
| 997 | + if (iteratesOwnLast) { |
| 998 | + forIn(value, function(objValue, objKey) { |
| 999 | + result = !hasOwnProperty.call(value, objKey); |
| 1000 | + return false; |
| 1001 | + }); |
| 1002 | + return result === false; |
| 1003 | + } |
| 1004 | + // In most environments an object's own properties are iterated before |
| 1005 | + // its inherited properties. If the last iterated property is an object's |
| 1006 | + // own property then there are no inherited enumerable properties. |
| 1007 | + forIn(value, function(objValue, objKey) { |
| 1008 | + result = objKey; |
| 1009 | + }); |
| 1010 | + return result === false || hasOwnProperty.call(value, result); |
| 1011 | + } |
| 1012 | + return result; |
| 1013 | + }; |
| 1014 | + } |
| 1015 | + |
1008 | 1016 | /**
|
1009 | 1017 | * A shim implementation of `Object.keys` that produces an array of the given
|
1010 | 1018 | * object's own enumerable property names.
|
|
0 commit comments