Skip to content

Commit

Permalink
Sync modules to vendor/core
Browse files Browse the repository at this point in the history
We haven't done this recently. Nothing has changed significantly, though
this does remove some files we weren't using.
  • Loading branch information
zpao committed Aug 16, 2013
1 parent d9511d8 commit 1f8ef4c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 104 deletions.
6 changes: 3 additions & 3 deletions src/vendor/core/$.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ 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 $,
* which will throw if the element doesn't exist.
*
* 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);
Expand Down
41 changes: 40 additions & 1 deletion src/vendor/core/createArrayFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions src/vendor/core/createObjectFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down
56 changes: 0 additions & 56 deletions src/vendor/core/hasArrayNature.js

This file was deleted.

39 changes: 0 additions & 39 deletions src/vendor/core/requestAnimationFrame.js

This file was deleted.

0 comments on commit 1f8ef4c

Please sign in to comment.