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.
Paul O’Shannessy committed
Aug 16, 2013 at 15:34 UTC
1f8ef4c90390287fa9931633ae6f3da950323942
5 files changed
+46
-104
src/vendor/core/$.js
+3
-3
@@ -21,9 +21,6 @@ var ge = require('ge');
21
var ex = require('ex');
22
23
/**
24
- * @param {string|DOMDocument|DOMElement|DOMTextNode} id
25
- * @return {DOMDocument|DOMElement|DOMTextNode}
26
- *
24
* Find a node by ID.
25
*
26
* If your application code depends on the existence of the element, use $,
@@ -31,6 +28,9 @@ var ex = require('ex');
28
*
29
* If you're not sure whether or not the element exists, use ge instead, and
30
* manually check for the element's existence in your application code.
31
+ *
32
+ * @param {string|DOMDocument|DOMElement|DOMTextNode|Comment} id
33
+ * @return {DOMDocument|DOMElement|DOMTextNode|Comment}
34
*/
35
function $(id) {
36
var element = ge(id);
src/vendor/core/createArrayFrom.js
+40
-1
@@ -17,7 +17,46 @@
17
* @typechecks
18
*/
19
20
-var hasArrayNature = require('hasArrayNature');
20
+/**
21
+ * NOTE: if you are a previous user of this function, it has been considered
22
+ * unsafe because it's inconsistent across browsers for some inputs.
23
+ * Instead use `Array.isArray()`.
24
+ *
25
+ * Perform a heuristic test to determine if an object is "array-like".
26
+ *
27
+ * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
28
+ * Joshu replied: "Mu."
29
+ *
30
+ * This function determines if its argument has "array nature": it returns
31
+ * true if the argument is an actual array, an `arguments' object, or an
32
+ * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
33
+ *
34
+ * @param {*} obj
35
+ * @return {boolean}
36
+ */
37
+function hasArrayNature(obj) {
38
+ return (
39
+ // not null/false
40
+ !!obj &&
41
+ // arrays are objects, NodeLists are functions in Safari
42
+ (typeof obj == 'object' || typeof obj == 'function') &&
43
+ // quacks like an array
44
+ ('length' in obj) &&
45
+ // not window
46
+ !('setInterval' in obj) &&
47
+ // no DOM node should be considered an array-like
48
+ // a 'select' element has 'length' and 'item' properties on IE8
49
+ (typeof obj.nodeType != 'number') &&
50
+ (
51
+ // a real array
52
+ Array.isArray(obj) ||
53
+ // arguments
54
+ ('callee' in obj) ||
55
+ // HTMLCollection/NodeList
56
+ ('item' in obj)
57
+ )
58
+ );
59
+}
60
61
/**
62
* Ensure that the argument is an array by wrapping it in an array if it is not.
src/vendor/core/createObjectFrom.js
+3
-5
@@ -16,8 +16,6 @@
16
* @providesModule createObjectFrom
17
*/
18
19
-var hasArrayNature = require('hasArrayNature');
20
-
19
/**
20
* Construct an object from an array of keys
21
* and optionally specified value or list of values.
@@ -43,19 +41,19 @@ var hasArrayNature = require('hasArrayNature');
41
*/
42
function createObjectFrom(keys, values /* = true */) {
43
if (__DEV__) {
46
- if (!hasArrayNature(keys)) {
44
+ if (!Array.isArray(keys)) {
45
throw new TypeError('Must pass an array of keys.');
46
}
47
}
48
49
var object = {};
52
- var is_array = hasArrayNature(values);
50
+ var isArray = Array.isArray(values);
51
if (typeof values == 'undefined') {
52
values = true;
53
}
54
55
for (var ii = keys.length; ii--;) {
58
- object[keys[ii]] = is_array ? values[ii] : values;
56
+ object[keys[ii]] = isArray ? values[ii] : values;
57
}
58
return object;
59
}
src/vendor/core/hasArrayNature.js
deleted
-56
@@ -1,56 +0,0 @@
1
-/**
2
- * Copyright 2013 Facebook, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- * @providesModule hasArrayNature
17
- */
18
-
19
-/**
20
- * Perform a heuristic test to determine if an object is "array-like".
21
- *
22
- * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
23
- * Joshu replied: "Mu."
24
- *
25
- * This function determines if its argument has "array nature": it returns
26
- * true if the argument is an actual array, an `arguments' object, or an
27
- * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
28
- *
29
- * @param obj An object to test.
30
- * @return bool True if the object is array-like.
31
- */
32
-function hasArrayNature(obj) {
33
- return (
34
- // not null/false
35
- !!obj &&
36
- // arrays are objects, NodeLists are functions in Safari
37
- (typeof obj == 'object' || typeof obj == 'function') &&
38
- // quacks like an array
39
- ('length' in obj) &&
40
- // not window
41
- !('setInterval' in obj) &&
42
- // no DOM node should be considered an array-like
43
- // a 'select' element has 'length' and 'item' properties
44
- (typeof obj.nodeType != 'number') &&
45
- (
46
- // a real array
47
- Array.isArray(obj) ||
48
- // arguments
49
- ('callee' in obj) ||
50
- // HTMLCollection/NodeList
51
- ('item' in obj)
52
- )
53
- );
54
-}
55
-
56
-module.exports = hasArrayNature;
src/vendor/core/requestAnimationFrame.js
deleted
-39
@@ -1,39 +0,0 @@
1
-/**
2
- * Copyright 2013 Facebook, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- * @providesModule requestAnimationFrame
17
- */
18
-
19
-var emptyFunction = require('emptyFunction');
20
-
21
-var lastTime = 0;
22
-
23
-var requestAnimationFrame =
24
- global.requestAnimationFrame ||
25
- global.webkitRequestAnimationFrame ||
26
- global.mozRequestAnimationFrame ||
27
- global.oRequestAnimationFrame ||
28
- global.msRequestAnimationFrame ||
29
- function(callback) {
30
- var currTime = Date.now();
31
- var timeDelay = Math.max(0, 16 - (currTime - lastTime));
32
- lastTime = currTime + timeDelay;
33
- return global.setTimeout(callback, timeDelay);
34
- };
35
-
36
-// Works around a rare bug in Safari 6 where the first request is never invoked.
37
-requestAnimationFrame(emptyFunction);
38
-
39
-module.exports = requestAnimationFrame;