diff --git a/src/vendor/core/$.js b/src/vendor/core/$.js index 95d63cf0bf..3918051c6b 100644 --- a/src/vendor/core/$.js +++ b/src/vendor/core/$.js @@ -21,9 +21,6 @@ var ge = require('ge'); var ex = require('ex'); /** - * @param {string|DOMDocument|DOMElement|DOMTextNode} id - * @return {DOMDocument|DOMElement|DOMTextNode} - * * Find a node by ID. * * If your application code depends on the existence of the element, use $, @@ -31,6 +28,9 @@ var ex = require('ex'); * * If you're not sure whether or not the element exists, use ge instead, and * manually check for the element's existence in your application code. + * + * @param {string|DOMDocument|DOMElement|DOMTextNode|Comment} id + * @return {DOMDocument|DOMElement|DOMTextNode|Comment} */ function $(id) { var element = ge(id); diff --git a/src/vendor/core/createArrayFrom.js b/src/vendor/core/createArrayFrom.js index 1924c0c241..22d1c75cde 100644 --- a/src/vendor/core/createArrayFrom.js +++ b/src/vendor/core/createArrayFrom.js @@ -17,7 +17,46 @@ * @typechecks */ -var hasArrayNature = require('hasArrayNature'); +/** + * NOTE: if you are a previous user of this function, it has been considered + * unsafe because it's inconsistent across browsers for some inputs. + * Instead use `Array.isArray()`. + * + * Perform a heuristic test to determine if an object is "array-like". + * + * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" + * Joshu replied: "Mu." + * + * This function determines if its argument has "array nature": it returns + * true if the argument is an actual array, an `arguments' object, or an + * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). + * + * @param {*} obj + * @return {boolean} + */ +function hasArrayNature(obj) { + return ( + // not null/false + !!obj && + // arrays are objects, NodeLists are functions in Safari + (typeof obj == 'object' || typeof obj == 'function') && + // quacks like an array + ('length' in obj) && + // not window + !('setInterval' in obj) && + // no DOM node should be considered an array-like + // a 'select' element has 'length' and 'item' properties on IE8 + (typeof obj.nodeType != 'number') && + ( + // a real array + Array.isArray(obj) || + // arguments + ('callee' in obj) || + // HTMLCollection/NodeList + ('item' in obj) + ) + ); +} /** * Ensure that the argument is an array by wrapping it in an array if it is not. diff --git a/src/vendor/core/createObjectFrom.js b/src/vendor/core/createObjectFrom.js index 4dda5c785d..918bbd8168 100644 --- a/src/vendor/core/createObjectFrom.js +++ b/src/vendor/core/createObjectFrom.js @@ -16,8 +16,6 @@ * @providesModule createObjectFrom */ -var hasArrayNature = require('hasArrayNature'); - /** * Construct an object from an array of keys * and optionally specified value or list of values. @@ -43,19 +41,19 @@ var hasArrayNature = require('hasArrayNature'); */ function createObjectFrom(keys, values /* = true */) { if (__DEV__) { - if (!hasArrayNature(keys)) { + if (!Array.isArray(keys)) { throw new TypeError('Must pass an array of keys.'); } } var object = {}; - var is_array = hasArrayNature(values); + var isArray = Array.isArray(values); if (typeof values == 'undefined') { values = true; } for (var ii = keys.length; ii--;) { - object[keys[ii]] = is_array ? values[ii] : values; + object[keys[ii]] = isArray ? values[ii] : values; } return object; } diff --git a/src/vendor/core/hasArrayNature.js b/src/vendor/core/hasArrayNature.js deleted file mode 100644 index dd7b84157c..0000000000 --- a/src/vendor/core/hasArrayNature.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @providesModule hasArrayNature - */ - -/** - * Perform a heuristic test to determine if an object is "array-like". - * - * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" - * Joshu replied: "Mu." - * - * This function determines if its argument has "array nature": it returns - * true if the argument is an actual array, an `arguments' object, or an - * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). - * - * @param obj An object to test. - * @return bool True if the object is array-like. - */ -function hasArrayNature(obj) { - return ( - // not null/false - !!obj && - // arrays are objects, NodeLists are functions in Safari - (typeof obj == 'object' || typeof obj == 'function') && - // quacks like an array - ('length' in obj) && - // not window - !('setInterval' in obj) && - // no DOM node should be considered an array-like - // a 'select' element has 'length' and 'item' properties - (typeof obj.nodeType != 'number') && - ( - // a real array - Array.isArray(obj) || - // arguments - ('callee' in obj) || - // HTMLCollection/NodeList - ('item' in obj) - ) - ); -} - -module.exports = hasArrayNature; diff --git a/src/vendor/core/requestAnimationFrame.js b/src/vendor/core/requestAnimationFrame.js deleted file mode 100644 index 090949c29f..0000000000 --- a/src/vendor/core/requestAnimationFrame.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @providesModule requestAnimationFrame - */ - -var emptyFunction = require('emptyFunction'); - -var lastTime = 0; - -var requestAnimationFrame = - global.requestAnimationFrame || - global.webkitRequestAnimationFrame || - global.mozRequestAnimationFrame || - global.oRequestAnimationFrame || - global.msRequestAnimationFrame || - function(callback) { - var currTime = Date.now(); - var timeDelay = Math.max(0, 16 - (currTime - lastTime)); - lastTime = currTime + timeDelay; - return global.setTimeout(callback, timeDelay); - }; - -// Works around a rare bug in Safari 6 where the first request is never invoked. -requestAnimationFrame(emptyFunction); - -module.exports = requestAnimationFrame;