mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Sync modules to vendor/core
We haven't done this recently. Nothing has changed significantly, though this does remove some files we weren't using.
This commit is contained in:
Vendored
+3
-3
@@ -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);
|
||||
|
||||
Vendored
+40
-1
@@ -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.
|
||||
|
||||
Vendored
+3
-5
@@ -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;
|
||||
}
|
||||
|
||||
Vendored
-56
@@ -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;
|
||||
-39
@@ -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;
|
||||
Reference in New Issue
Block a user