@samitouri / QOS-React-2 / commits / 46d05b1191
Fork 0

The library for web and native user interfaces.

Sync vendor modules from FB.

Biggest win here is that we'll strip out the console.error from EventListener and we won't need to suggest people use a console polyfill with the minified build.

Paul O’Shannessy committed Jul 15, 2013 at 21:04 UTC 46d05b1191d2035657ca3bd3dc24967b4706bd74
5 files changed +34 -34
src/vendor/core/$.js
+11 -11
@@ -14,11 +14,16 @@
14 * limitations under the License.
15 *
16 * @providesModule $
17 + * @typechecks
18 */
19
20 var ge = require('ge');
21 +var ex = require('ex');
22
23 /**
24 + * @param {string|DOMDocument|DOMElement|DOMTextNode} id
25 + * @return {DOMDocument|DOMElement|DOMTextNode}
26 + *
27 * Find a node by ID.
28 *
29 * If your application code depends on the existence of the element, use $,
@@ -27,18 +32,13 @@ var ge = require('ge');
32 * If you're not sure whether or not the element exists, use ge instead, and
33 * manually check for the element's existence in your application code.
34 */
30 -function $(arg) {
31 - var element = ge(arg);
35 +function $(id) {
36 + var element = ge(id);
37 if (!element) {
33 - if (typeof arg == 'undefined') {
34 - arg = 'undefined';
35 - } else if (arg === null) {
36 - arg = 'null';
37 - }
38 - throw new Error(
39 - 'Tried to get element "' + arg.toString() + '" but it is not present ' +
40 - 'on the page.'
41 - );
38 + throw new Error(ex(
39 + 'Tried to get element with id of "%s" but it is not present on the page.',
40 + id
41 + ));
42 }
43 return element;
44 }
src/vendor/core/emptyFunction.js
+1 -8
@@ -37,14 +37,7 @@ copyProperties(emptyFunction, {
37 thatReturnsTrue: makeEmptyFunction(true),
38 thatReturnsNull: makeEmptyFunction(null),
39 thatReturnsThis: function() { return this; },
40 - thatReturnsArgument: function(arg) { return arg; },
41 - mustImplement: function(module, property) {
42 - return function() {
43 - if (__DEV__) {
44 - throw new Error(module + '.' + property + ' must be implemented!');
45 - }
46 - };
47 - }
40 + thatReturnsArgument: function(arg) { return arg; }
41 });
42
43 module.exports = emptyFunction;
src/vendor/core/hasArrayNature.js
+4 -1
@@ -39,9 +39,12 @@ function hasArrayNature(obj) {
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
44 - Object.prototype.toString.call(obj) === "[object Array]" ||
47 + Array.isArray(obj) ||
48 // arguments
49 ('callee' in obj) ||
50 // HTMLCollection/NodeList
src/vendor/core/requestAnimationFrame.js
+11 -9
@@ -18,17 +18,19 @@
18
19 var emptyFunction = require('emptyFunction');
20
21 +var lastTime = 0;
22 +
23 var requestAnimationFrame =
22 - window.requestAnimationFrame ||
23 - window.webkitRequestAnimationFrame ||
24 - window.mozRequestAnimationFrame ||
25 - window.oRequestAnimationFrame ||
26 - window.msRequestAnimationFrame ||
24 + global.requestAnimationFrame ||
25 + global.webkitRequestAnimationFrame ||
26 + global.mozRequestAnimationFrame ||
27 + global.oRequestAnimationFrame ||
28 + global.msRequestAnimationFrame ||
29 function(callback) {
28 - // Browsers which don't support requestAnimationFrame are likely running on
29 - // older hardware, so it's not reasonable to expect 60FPS animations out of
30 - // them. 30FPS (33.3ms per frame) is more reasonable.
31 - return window.setTimeout(callback, 33);
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.
src/vendor/stubs/EventListener.js
+7 -5
@@ -44,11 +44,13 @@ var EventListener = {
44 */
45 capture: function(el, handlerBaseName, cb) {
46 if (!el.addEventListener) {
47 - console.error(
48 - 'You are attempting to use addEventlistener ' +
49 - 'in a browser that does not support it support it.' +
50 - 'This likely means that you will not receive events that ' +
51 - 'your application relies on (such as scroll).');
47 + if (__DEV__) {
48 + console.error(
49 + 'You are attempting to use addEventlistener ' +
50 + 'in a browser that does not support it support it.' +
51 + 'This likely means that you will not receive events that ' +
52 + 'your application relies on (such as scroll).');
53 + }
54 return;
55 } else {
56 el.addEventListener(handlerBaseName, cb, true);