mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Sync more vendored modules
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2014 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 focusNode
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* IE8 throws if an input/textarea is disabled and we try to focus it.
|
||||
* Focus only when necessary.
|
||||
*
|
||||
* @param {DOMElement} node input/textarea to focus
|
||||
*/
|
||||
function focusNode(node) {
|
||||
if (!node.disabled) {
|
||||
node.focus();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = focusNode;
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright 2013-2014 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 emptyObject
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var emptyObject = {};
|
||||
|
||||
if (__DEV__) {
|
||||
Object.freeze(emptyObject);
|
||||
}
|
||||
|
||||
module.exports = emptyObject;
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2014 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 monitorCodeUse
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var invariant = require('invariant');
|
||||
|
||||
/**
|
||||
* Provides open-source compatible instrumentation for monitoring certain API
|
||||
* uses before we're ready to issue a warning or refactor. It accepts an event
|
||||
* name which may only contain the characters [a-z0-9_] and an optional data
|
||||
* object with further information.
|
||||
*/
|
||||
|
||||
function monitorCodeUse(eventName, data) {
|
||||
invariant(
|
||||
eventName && !/[^a-z0-9_]/.test(eventName),
|
||||
'You must provide an eventName using only the characters [a-z0-9_]'
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = monitorCodeUse;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright 2014 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 nativeRequestAnimationFrame
|
||||
*/
|
||||
|
||||
var nativeRequestAnimationFrame =
|
||||
global.requestAnimationFrame ||
|
||||
global.webkitRequestAnimationFrame ||
|
||||
global.mozRequestAnimationFrame ||
|
||||
global.oRequestAnimationFrame ||
|
||||
global.msRequestAnimationFrame;
|
||||
|
||||
module.exports = nativeRequestAnimationFrame;
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2014 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 nativeRequestAnimationFrame = require('nativeRequestAnimationFrame');
|
||||
|
||||
var lastTime = 0;
|
||||
|
||||
var requestAnimationFrame =
|
||||
nativeRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
var currTime = Date.now();
|
||||
var timeDelay = Math.max(0, 16 - (currTime - lastTime));
|
||||
lastTime = currTime + timeDelay;
|
||||
return global.setTimeout(function() {
|
||||
callback(Date.now());
|
||||
}, 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