react 0.11.2 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSXTransformer.js +2714 -7859
- package/dist/react-with-addons.js +3139 -3593
- package/dist/react-with-addons.min.js +11 -17
- package/dist/react.js +2940 -3308
- package/dist/react.min.js +11 -16
- package/lib/AutoFocusMixin.js +5 -12
- package/lib/BeforeInputEventPlugin.js +12 -14
- package/lib/CSSCore.js +6 -13
- package/lib/CSSProperty.js +10 -14
- package/lib/CSSPropertyOperations.js +46 -12
- package/lib/CallbackQueue.js +7 -14
- package/lib/ChangeEventPlugin.js +5 -12
- package/lib/ClientReactRootIndex.js +5 -12
- package/lib/CompositionEventPlugin.js +5 -12
- package/lib/DOMChildrenOperations.js +8 -15
- package/lib/DOMProperty.js +16 -19
- package/lib/DOMPropertyOperations.js +14 -14
- package/lib/Danger.js +12 -17
- package/lib/DefaultEventPluginOrder.js +5 -12
- package/lib/EnterLeaveEventPlugin.js +5 -12
- package/lib/EventConstants.js +5 -12
- package/lib/EventListener.js +14 -0
- package/lib/EventPluginHub.js +8 -26
- package/lib/EventPluginRegistry.js +5 -12
- package/lib/EventPluginUtils.js +5 -12
- package/lib/EventPropagators.js +12 -17
- package/lib/ExecutionEnvironment.js +5 -12
- package/lib/HTMLDOMPropertyConfig.js +16 -15
- package/lib/LinkedStateMixin.js +5 -12
- package/lib/LinkedValueUtils.js +5 -12
- package/lib/LocalEventTrapMixin.js +8 -14
- package/lib/MobileSafariClickEventPlugin.js +5 -12
- package/lib/Object.assign.js +45 -0
- package/lib/PooledClass.js +5 -12
- package/lib/React.js +87 -54
- package/lib/ReactBrowserComponentMixin.js +5 -12
- package/lib/ReactBrowserEventEmitter.js +7 -14
- package/lib/ReactCSSTransitionGroup.js +15 -17
- package/lib/ReactCSSTransitionGroupChild.js +9 -13
- package/lib/ReactChildren.js +5 -12
- package/lib/ReactComponent.js +61 -68
- package/lib/ReactComponentBrowserEnvironment.js +5 -12
- package/lib/ReactComponentWithPureRenderMixin.js +5 -12
- package/lib/ReactCompositeComponent.js +191 -180
- package/lib/ReactContext.js +8 -15
- package/lib/ReactCurrentOwner.js +5 -12
- package/lib/ReactDOM.js +145 -177
- package/lib/ReactDOMButton.js +8 -14
- package/lib/ReactDOMComponent.js +103 -38
- package/lib/ReactDOMForm.js +9 -15
- package/lib/ReactDOMIDOperations.js +5 -12
- package/lib/ReactDOMImg.js +8 -14
- package/lib/ReactDOMInput.js +30 -38
- package/lib/ReactDOMOption.js +8 -14
- package/lib/ReactDOMSelect.js +25 -24
- package/lib/ReactDOMSelection.js +11 -18
- package/lib/ReactDOMTextarea.js +19 -24
- package/lib/ReactDefaultBatchingStrategy.js +14 -18
- package/lib/ReactDefaultInjection.js +23 -26
- package/lib/ReactDefaultPerf.js +14 -17
- package/lib/ReactDefaultPerfAnalysis.js +18 -17
- package/lib/ReactElement.js +242 -0
- package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
- package/lib/ReactEmptyComponent.js +8 -13
- package/lib/ReactErrorUtils.js +5 -12
- package/lib/ReactEventEmitterMixin.js +5 -12
- package/lib/ReactEventListener.js +7 -14
- package/lib/ReactInjection.js +7 -14
- package/lib/ReactInputSelection.js +5 -12
- package/lib/ReactInstanceHandles.js +5 -12
- package/lib/ReactLegacyElement.js +243 -0
- package/lib/ReactLink.js +5 -12
- package/lib/ReactMarkupChecksum.js +5 -12
- package/lib/ReactMount.js +45 -32
- package/lib/ReactMultiChild.js +14 -18
- package/lib/ReactMultiChildUpdateTypes.js +5 -12
- package/lib/ReactNativeComponent.js +69 -0
- package/lib/ReactOwner.js +5 -12
- package/lib/ReactPerf.js +8 -13
- package/lib/ReactPropTransferer.js +34 -33
- package/lib/ReactPropTypeLocationNames.js +5 -12
- package/lib/ReactPropTypeLocations.js +5 -12
- package/lib/ReactPropTypes.js +38 -29
- package/lib/ReactPutListenerQueue.js +7 -14
- package/lib/ReactReconcileTransaction.js +7 -15
- package/lib/ReactRootIndex.js +5 -12
- package/lib/ReactServerRendering.js +21 -34
- package/lib/ReactServerRenderingTransaction.js +11 -15
- package/lib/ReactStateSetters.js +5 -12
- package/lib/ReactTestUtils.js +31 -33
- package/lib/ReactTextComponent.js +18 -21
- package/lib/ReactTransitionChildMapping.js +6 -13
- package/lib/ReactTransitionEvents.js +5 -12
- package/lib/ReactTransitionGroup.js +14 -17
- package/lib/ReactUpdates.js +43 -22
- package/lib/ReactWithAddons.js +7 -13
- package/lib/SVGDOMPropertyConfig.js +5 -12
- package/lib/SelectEventPlugin.js +13 -20
- package/lib/ServerReactRootIndex.js +5 -12
- package/lib/SimpleEventPlugin.js +20 -15
- package/lib/SyntheticClipboardEvent.js +5 -12
- package/lib/SyntheticCompositionEvent.js +5 -12
- package/lib/SyntheticDragEvent.js +5 -12
- package/lib/SyntheticEvent.js +9 -17
- package/lib/SyntheticFocusEvent.js +5 -12
- package/lib/SyntheticInputEvent.js +4 -11
- package/lib/SyntheticKeyboardEvent.js +17 -19
- package/lib/SyntheticMouseEvent.js +5 -12
- package/lib/SyntheticTouchEvent.js +5 -12
- package/lib/SyntheticUIEvent.js +5 -12
- package/lib/SyntheticWheelEvent.js +5 -12
- package/lib/Transaction.js +5 -12
- package/lib/ViewportMetrics.js +5 -12
- package/lib/accumulateInto.js +62 -0
- package/lib/adler32.js +6 -13
- package/lib/camelize.js +30 -0
- package/lib/camelizeStyleName.js +40 -0
- package/lib/cloneWithProps.js +9 -15
- package/lib/containsNode.js +5 -12
- package/lib/copyProperties.js +12 -12
- package/lib/createArrayFrom.js +5 -12
- package/lib/createFullPageComponent.js +12 -18
- package/lib/createNodesFromMarkup.js +5 -12
- package/lib/cx.js +5 -12
- package/lib/dangerousStyleValue.js +5 -12
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +11 -22
- package/lib/emptyObject.js +5 -12
- package/lib/escapeTextForBrowser.js +5 -12
- package/lib/flattenChildren.js +19 -13
- package/lib/focusNode.js +10 -16
- package/lib/forEachAccumulated.js +5 -12
- package/lib/getActiveElement.js +5 -12
- package/lib/getEventCharCode.js +50 -0
- package/lib/getEventKey.js +9 -21
- package/lib/getEventModifierState.js +4 -11
- package/lib/getEventTarget.js +5 -12
- package/lib/getMarkupWrap.js +5 -12
- package/lib/getNodeForCharacterOffset.js +5 -12
- package/lib/getReactRootElementInContainer.js +5 -12
- package/lib/getTextContentAccessor.js +5 -12
- package/lib/getUnboundedScrollPosition.js +5 -12
- package/lib/hyphenate.js +5 -12
- package/lib/hyphenateStyleName.js +8 -15
- package/lib/instantiateReactComponent.js +90 -42
- package/lib/invariant.js +5 -12
- package/lib/isEventSupported.js +5 -12
- package/lib/isNode.js +5 -12
- package/lib/isTextInputElement.js +5 -12
- package/lib/isTextNode.js +5 -12
- package/lib/joinClasses.js +8 -13
- package/lib/keyMirror.js +5 -12
- package/lib/keyOf.js +5 -12
- package/lib/mapObject.js +35 -36
- package/lib/memoizeStringOnly.js +5 -12
- package/lib/merge.js +14 -17
- package/lib/mergeInto.js +13 -35
- package/lib/monitorCodeUse.js +5 -12
- package/lib/onlyChild.js +8 -15
- package/lib/performance.js +5 -12
- package/lib/performanceNow.js +5 -12
- package/lib/setInnerHTML.js +10 -19
- package/lib/shallowEqual.js +6 -13
- package/lib/shouldUpdateReactComponent.js +14 -22
- package/lib/toArray.js +5 -12
- package/lib/traverseAllChildren.js +34 -48
- package/lib/update.js +8 -15
- package/lib/warning.js +6 -13
- package/package.json +3 -8
- package/lib/ReactDescriptor.js +0 -251
- package/lib/accumulate.js +0 -54
- package/lib/mergeHelpers.js +0 -147
- package/lib/mixInto.js +0 -34
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule createNodesFromMarkup
|
|
17
10
|
* @typechecks
|
package/lib/cx.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule cx
|
|
17
10
|
*/
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule dangerousStyleValue
|
|
17
10
|
* @typechecks static-only
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule deprecated
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var assign = require("./Object.assign");
|
|
13
|
+
var warning = require("./warning");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This will log a single deprecation notice per function and forward the call
|
|
17
|
+
* on to the new API.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} namespace The namespace of the call, eg 'React'
|
|
20
|
+
* @param {string} oldName The old function name, eg 'renderComponent'
|
|
21
|
+
* @param {string} newName The new function name, eg 'render'
|
|
22
|
+
* @param {*} ctx The context this forwarded call should run in
|
|
23
|
+
* @param {function} fn The function to forward on to
|
|
24
|
+
* @return {*} Will be the value as returned from `fn`
|
|
25
|
+
*/
|
|
26
|
+
function deprecated(namespace, oldName, newName, ctx, fn) {
|
|
27
|
+
var warned = false;
|
|
28
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
29
|
+
var newFn = function() {
|
|
30
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
31
|
+
warned,
|
|
32
|
+
(namespace + "." + oldName + " will be deprecated in a future version. ") +
|
|
33
|
+
("Use " + namespace + "." + newName + " instead.")
|
|
34
|
+
) : null);
|
|
35
|
+
warned = true;
|
|
36
|
+
return fn.apply(ctx, arguments);
|
|
37
|
+
};
|
|
38
|
+
newFn.displayName = (namespace + "_" + oldName);
|
|
39
|
+
// We need to make sure all properties of the original fn are copied over.
|
|
40
|
+
// In particular, this is needed to support PropTypes
|
|
41
|
+
return assign(newFn, fn);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return fn;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = deprecated;
|
package/lib/emptyFunction.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule emptyFunction
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
|
-
var copyProperties = require("./copyProperties");
|
|
20
|
-
|
|
21
12
|
function makeEmptyFunction(arg) {
|
|
22
13
|
return function() {
|
|
23
14
|
return arg;
|
|
@@ -31,13 +22,11 @@ function makeEmptyFunction(arg) {
|
|
|
31
22
|
*/
|
|
32
23
|
function emptyFunction() {}
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
thatReturnsArgument: function(arg) { return arg; }
|
|
41
|
-
});
|
|
25
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
|
26
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
27
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
28
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
29
|
+
emptyFunction.thatReturnsThis = function() { return this; };
|
|
30
|
+
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
|
|
42
31
|
|
|
43
32
|
module.exports = emptyFunction;
|
package/lib/emptyObject.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule emptyObject
|
|
17
10
|
*/
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule escapeTextForBrowser
|
|
17
10
|
* @typechecks static-only
|
package/lib/flattenChildren.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule flattenChildren
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
12
|
"use strict";
|
|
20
13
|
|
|
14
|
+
var ReactTextComponent = require("./ReactTextComponent");
|
|
15
|
+
|
|
21
16
|
var traverseAllChildren = require("./traverseAllChildren");
|
|
22
17
|
var warning = require("./warning");
|
|
23
18
|
|
|
@@ -38,7 +33,18 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
|
38
33
|
name
|
|
39
34
|
) : null);
|
|
40
35
|
if (keyUnique && child != null) {
|
|
41
|
-
|
|
36
|
+
var type = typeof child;
|
|
37
|
+
var normalizedValue;
|
|
38
|
+
|
|
39
|
+
if (type === 'string') {
|
|
40
|
+
normalizedValue = ReactTextComponent(child);
|
|
41
|
+
} else if (type === 'number') {
|
|
42
|
+
normalizedValue = ReactTextComponent('' + child);
|
|
43
|
+
} else {
|
|
44
|
+
normalizedValue = child;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
result[name] = normalizedValue;
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
|
package/lib/focusNode.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule focusNode
|
|
17
10
|
*/
|
|
@@ -19,14 +12,15 @@
|
|
|
19
12
|
"use strict";
|
|
20
13
|
|
|
21
14
|
/**
|
|
22
|
-
* IE8 throws if an input/textarea is disabled and we try to focus it.
|
|
23
|
-
* Focus only when necessary.
|
|
24
|
-
*
|
|
25
15
|
* @param {DOMElement} node input/textarea to focus
|
|
26
16
|
*/
|
|
27
17
|
function focusNode(node) {
|
|
28
|
-
|
|
18
|
+
// IE8 can throw "Can't move focus to the control because it is invisible,
|
|
19
|
+
// not enabled, or of a type that does not accept the focus." for all kinds of
|
|
20
|
+
// reasons that are too expensive and fragile to test.
|
|
21
|
+
try {
|
|
29
22
|
node.focus();
|
|
23
|
+
} catch(e) {
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
26
|
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule forEachAccumulated
|
|
17
10
|
*/
|
package/lib/getActiveElement.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule getActiveElement
|
|
17
10
|
* @typechecks
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule getEventCharCode
|
|
10
|
+
* @typechecks static-only
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `charCode` represents the actual "character code" and is safe to use with
|
|
17
|
+
* `String.fromCharCode`. As such, only keys that correspond to printable
|
|
18
|
+
* characters produce a valid `charCode`, the only exception to this is Enter.
|
|
19
|
+
* The Tab-key is considered non-printable and does not have a `charCode`,
|
|
20
|
+
* presumably because it does not produce a tab-character in browsers.
|
|
21
|
+
*
|
|
22
|
+
* @param {object} nativeEvent Native browser event.
|
|
23
|
+
* @return {string} Normalized `charCode` property.
|
|
24
|
+
*/
|
|
25
|
+
function getEventCharCode(nativeEvent) {
|
|
26
|
+
var charCode;
|
|
27
|
+
var keyCode = nativeEvent.keyCode;
|
|
28
|
+
|
|
29
|
+
if ('charCode' in nativeEvent) {
|
|
30
|
+
charCode = nativeEvent.charCode;
|
|
31
|
+
|
|
32
|
+
// FF does not set `charCode` for the Enter-key, check against `keyCode`.
|
|
33
|
+
if (charCode === 0 && keyCode === 13) {
|
|
34
|
+
charCode = 13;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// IE8 does not implement `charCode`, but `keyCode` has the correct value.
|
|
38
|
+
charCode = keyCode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
|
|
42
|
+
// Must not discard the (non-)printable Enter-key.
|
|
43
|
+
if (charCode >= 32 || charCode === 13) {
|
|
44
|
+
return charCode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = getEventCharCode;
|
package/lib/getEventKey.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule getEventKey
|
|
17
10
|
* @typechecks static-only
|
|
@@ -19,7 +12,7 @@
|
|
|
19
12
|
|
|
20
13
|
"use strict";
|
|
21
14
|
|
|
22
|
-
var
|
|
15
|
+
var getEventCharCode = require("./getEventCharCode");
|
|
23
16
|
|
|
24
17
|
/**
|
|
25
18
|
* Normalization of deprecated HTML5 `key` values
|
|
@@ -41,7 +34,7 @@ var normalizeKey = {
|
|
|
41
34
|
};
|
|
42
35
|
|
|
43
36
|
/**
|
|
44
|
-
* Translation from legacy `
|
|
37
|
+
* Translation from legacy `keyCode` to HTML5 `key`
|
|
45
38
|
* Only special keys supported, all others depend on keyboard layout or browser
|
|
46
39
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
47
40
|
*/
|
|
@@ -93,11 +86,7 @@ function getEventKey(nativeEvent) {
|
|
|
93
86
|
|
|
94
87
|
// Browser does not implement `key`, polyfill as much of it as we can.
|
|
95
88
|
if (nativeEvent.type === 'keypress') {
|
|
96
|
-
|
|
97
|
-
// perfect replacement.
|
|
98
|
-
var charCode = 'charCode' in nativeEvent ?
|
|
99
|
-
nativeEvent.charCode :
|
|
100
|
-
nativeEvent.keyCode;
|
|
89
|
+
var charCode = getEventCharCode(nativeEvent);
|
|
101
90
|
|
|
102
91
|
// The enter-key is technically both printable and non-printable and can
|
|
103
92
|
// thus be captured by `keypress`, no other non-printable key should.
|
|
@@ -108,8 +97,7 @@ function getEventKey(nativeEvent) {
|
|
|
108
97
|
// `keyCode` value, almost all function keys have a universal value.
|
|
109
98
|
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
|
|
110
99
|
}
|
|
111
|
-
|
|
112
|
-
("production" !== process.env.NODE_ENV ? invariant(false, "Unexpected keyboard event type: %s", nativeEvent.type) : invariant(false));
|
|
100
|
+
return '';
|
|
113
101
|
}
|
|
114
102
|
|
|
115
103
|
module.exports = getEventKey;
|