diff --git a/src/vendor/core/dom/focusNode.js b/src/vendor/core/dom/focusNode.js new file mode 100644 index 0000000000..9c7723e493 --- /dev/null +++ b/src/vendor/core/dom/focusNode.js @@ -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; diff --git a/src/vendor/core/emptyObject.js b/src/vendor/core/emptyObject.js new file mode 100644 index 0000000000..204bd3b1b8 --- /dev/null +++ b/src/vendor/core/emptyObject.js @@ -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; diff --git a/src/vendor/core/monitorCodeUse.js b/src/vendor/core/monitorCodeUse.js new file mode 100644 index 0000000000..2943630c26 --- /dev/null +++ b/src/vendor/core/monitorCodeUse.js @@ -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; diff --git a/src/vendor/core/nativeRequestAnimationFrame.js b/src/vendor/core/nativeRequestAnimationFrame.js new file mode 100644 index 0000000000..0218838974 --- /dev/null +++ b/src/vendor/core/nativeRequestAnimationFrame.js @@ -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; diff --git a/src/vendor/core/requestAnimationFrame.js b/src/vendor/core/requestAnimationFrame.js new file mode 100644 index 0000000000..acdd1c9d4a --- /dev/null +++ b/src/vendor/core/requestAnimationFrame.js @@ -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;