@samitouri / QOS-React-2 / commits / 4c4446d283

Sync more vendored modules

Paul O’Shannessy committed Mar 3, 2014 at 15:34 UTC 4c4446d283552f9280305eaeda26be97680ff454
5 files changed +161
src/vendor/core/dom/focusNode.js new
+33
@@ -0,0 +1,33 @@
1 +/**
2 + * Copyright 2014 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 focusNode
17 + */
18 +
19 +"use strict";
20 +
21 +/**
22 + * IE8 throws if an input/textarea is disabled and we try to focus it.
23 + * Focus only when necessary.
24 + *
25 + * @param {DOMElement} node input/textarea to focus
26 + */
27 +function focusNode(node) {
28 + if (!node.disabled) {
29 + node.focus();
30 + }
31 +}
32 +
33 +module.exports = focusNode;
src/vendor/core/emptyObject.js new
+27
@@ -0,0 +1,27 @@
1 +/**
2 + * Copyright 2013-2014 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 emptyObject
17 + */
18 +
19 +"use strict";
20 +
21 +var emptyObject = {};
22 +
23 +if (__DEV__) {
24 + Object.freeze(emptyObject);
25 +}
26 +
27 +module.exports = emptyObject;
src/vendor/core/monitorCodeUse.js new
+37
@@ -0,0 +1,37 @@
1 +/**
2 + * Copyright 2014 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 monitorCodeUse
17 + */
18 +
19 +"use strict";
20 +
21 +var invariant = require('invariant');
22 +
23 +/**
24 + * Provides open-source compatible instrumentation for monitoring certain API
25 + * uses before we're ready to issue a warning or refactor. It accepts an event
26 + * name which may only contain the characters [a-z0-9_] and an optional data
27 + * object with further information.
28 + */
29 +
30 +function monitorCodeUse(eventName, data) {
31 + invariant(
32 + eventName && !/[^a-z0-9_]/.test(eventName),
33 + 'You must provide an eventName using only the characters [a-z0-9_]'
34 + );
35 +}
36 +
37 +module.exports = monitorCodeUse;
src/vendor/core/nativeRequestAnimationFrame.js new
+26
@@ -0,0 +1,26 @@
1 +/**
2 + * Copyright 2014 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 nativeRequestAnimationFrame
17 + */
18 +
19 +var nativeRequestAnimationFrame =
20 + global.requestAnimationFrame ||
21 + global.webkitRequestAnimationFrame ||
22 + global.mozRequestAnimationFrame ||
23 + global.oRequestAnimationFrame ||
24 + global.msRequestAnimationFrame;
25 +
26 +module.exports = nativeRequestAnimationFrame;
src/vendor/core/requestAnimationFrame.js new
+38
@@ -0,0 +1,38 @@
1 +/**
2 + * Copyright 2014 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 +var nativeRequestAnimationFrame = require('nativeRequestAnimationFrame');
21 +
22 +var lastTime = 0;
23 +
24 +var requestAnimationFrame =
25 + nativeRequestAnimationFrame ||
26 + function(callback) {
27 + var currTime = Date.now();
28 + var timeDelay = Math.max(0, 16 - (currTime - lastTime));
29 + lastTime = currTime + timeDelay;
30 + return global.setTimeout(function() {
31 + callback(Date.now());
32 + }, timeDelay);
33 + };
34 +
35 +// Works around a rare bug in Safari 6 where the first request is never invoked.
36 +requestAnimationFrame(emptyFunction);
37 +
38 +module.exports = requestAnimationFrame;