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.
This commit is contained in:
Paul O’Shannessy
2013-07-15 21:04:43 -07:00
parent 558e8ca312
commit 46d05b1191
5 changed files with 34 additions and 34 deletions
+11 -11
View File
@@ -14,11 +14,16 @@
* limitations under the License.
*
* @providesModule $
* @typechecks
*/
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 $,
@@ -27,18 +32,13 @@ var ge = require('ge');
* 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.
*/
function $(arg) {
var element = ge(arg);
function $(id) {
var element = ge(id);
if (!element) {
if (typeof arg == 'undefined') {
arg = 'undefined';
} else if (arg === null) {
arg = 'null';
}
throw new Error(
'Tried to get element "' + arg.toString() + '" but it is not present ' +
'on the page.'
);
throw new Error(ex(
'Tried to get element with id of "%s" but it is not present on the page.',
id
));
}
return element;
}
+1 -8
View File
@@ -37,14 +37,7 @@ copyProperties(emptyFunction, {
thatReturnsTrue: makeEmptyFunction(true),
thatReturnsNull: makeEmptyFunction(null),
thatReturnsThis: function() { return this; },
thatReturnsArgument: function(arg) { return arg; },
mustImplement: function(module, property) {
return function() {
if (__DEV__) {
throw new Error(module + '.' + property + ' must be implemented!');
}
};
}
thatReturnsArgument: function(arg) { return arg; }
});
module.exports = emptyFunction;
+4 -1
View File
@@ -39,9 +39,12 @@ function hasArrayNature(obj) {
('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
Object.prototype.toString.call(obj) === "[object Array]" ||
Array.isArray(obj) ||
// arguments
('callee' in obj) ||
// HTMLCollection/NodeList
+11 -9
View File
@@ -18,17 +18,19 @@
var emptyFunction = require('emptyFunction');
var lastTime = 0;
var requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
global.requestAnimationFrame ||
global.webkitRequestAnimationFrame ||
global.mozRequestAnimationFrame ||
global.oRequestAnimationFrame ||
global.msRequestAnimationFrame ||
function(callback) {
// Browsers which don't support requestAnimationFrame are likely running on
// older hardware, so it's not reasonable to expect 60FPS animations out of
// them. 30FPS (33.3ms per frame) is more reasonable.
return window.setTimeout(callback, 33);
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.
+7 -5
View File
@@ -44,11 +44,13 @@ var EventListener = {
*/
capture: function(el, handlerBaseName, cb) {
if (!el.addEventListener) {
console.error(
'You are attempting to use addEventlistener ' +
'in a browser that does not support it support it.' +
'This likely means that you will not receive events that ' +
'your application relies on (such as scroll).');
if (__DEV__) {
console.error(
'You are attempting to use addEventlistener ' +
'in a browser that does not support it support it.' +
'This likely means that you will not receive events that ' +
'your application relies on (such as scroll).');
}
return;
} else {
el.addEventListener(handlerBaseName, cb, true);