react 0.7.1 → 0.8.0

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.
Files changed (203) hide show
  1. package/README.md +15 -228
  2. package/ReactJSErrors.js +40 -0
  3. package/addons.js +4 -0
  4. package/lib/$.js +46 -0
  5. package/lib/CSSCore.js +114 -0
  6. package/lib/CSSProperty.js +90 -0
  7. package/lib/CSSPropertyOperations.js +97 -0
  8. package/lib/CallbackRegistry.js +91 -0
  9. package/lib/ChangeEventPlugin.js +365 -0
  10. package/lib/CompositionEventPlugin.js +212 -0
  11. package/lib/DOMChildrenOperations.js +135 -0
  12. package/lib/DOMProperty.js +266 -0
  13. package/lib/DOMPropertyOperations.js +168 -0
  14. package/lib/Danger.js +186 -0
  15. package/lib/DefaultDOMPropertyConfig.js +187 -0
  16. package/lib/DefaultEventPluginOrder.js +44 -0
  17. package/lib/EnterLeaveEventPlugin.js +112 -0
  18. package/lib/EventConstants.js +73 -0
  19. package/lib/EventListener.js +61 -0
  20. package/lib/EventPluginHub.js +190 -0
  21. package/lib/EventPluginRegistry.js +237 -0
  22. package/lib/EventPluginUtils.js +185 -0
  23. package/lib/EventPropagators.js +179 -0
  24. package/lib/ExecutionEnvironment.js +41 -0
  25. package/lib/LinkedStateMixin.js +46 -0
  26. package/lib/LinkedValueMixin.js +68 -0
  27. package/lib/MobileSafariClickEventPlugin.js +63 -0
  28. package/lib/PooledClass.js +113 -0
  29. package/lib/React.js +71 -0
  30. package/lib/ReactChildren.js +132 -0
  31. package/lib/ReactComponent.js +515 -0
  32. package/lib/ReactComponentBrowserEnvironment.js +140 -0
  33. package/lib/ReactComponentEnvironment.js +24 -0
  34. package/lib/ReactCompositeComponent.js +1020 -0
  35. package/lib/ReactCurrentOwner.js +39 -0
  36. package/lib/ReactDOM.js +194 -0
  37. package/lib/ReactDOMButton.js +64 -0
  38. package/lib/ReactDOMComponent.js +374 -0
  39. package/lib/ReactDOMForm.js +52 -0
  40. package/lib/ReactDOMIDOperations.js +173 -0
  41. package/lib/ReactDOMInput.js +169 -0
  42. package/lib/ReactDOMOption.js +50 -0
  43. package/lib/ReactDOMSelect.js +160 -0
  44. package/lib/ReactDOMSelection.js +189 -0
  45. package/lib/ReactDOMTextarea.js +136 -0
  46. package/lib/ReactDefaultBatchingStrategy.js +75 -0
  47. package/lib/ReactDefaultInjection.js +91 -0
  48. package/lib/ReactDefaultPerf.js +407 -0
  49. package/lib/ReactErrorUtils.js +46 -0
  50. package/lib/ReactEventEmitter.js +341 -0
  51. package/lib/ReactEventEmitterMixin.js +89 -0
  52. package/lib/ReactEventTopLevelCallback.js +89 -0
  53. package/lib/ReactInputSelection.js +140 -0
  54. package/lib/ReactInstanceHandles.js +322 -0
  55. package/lib/ReactLink.js +54 -0
  56. package/lib/ReactMarkupChecksum.js +53 -0
  57. package/lib/ReactMount.js +617 -0
  58. package/lib/ReactMountReady.js +95 -0
  59. package/lib/ReactMultiChild.js +441 -0
  60. package/lib/ReactMultiChildUpdateTypes.js +36 -0
  61. package/lib/ReactOwner.js +146 -0
  62. package/lib/ReactPerf.js +88 -0
  63. package/lib/ReactPropTransferer.js +128 -0
  64. package/lib/ReactPropTypes.js +158 -0
  65. package/lib/ReactReconcileTransaction.js +161 -0
  66. package/lib/ReactServerRendering.js +62 -0
  67. package/lib/ReactStateSetters.js +111 -0
  68. package/lib/ReactTextComponent.js +94 -0
  69. package/lib/ReactTransitionEvents.js +97 -0
  70. package/lib/ReactTransitionGroup.js +112 -0
  71. package/lib/ReactTransitionKeySet.js +111 -0
  72. package/lib/ReactTransitionableChild.js +152 -0
  73. package/lib/ReactUpdates.js +145 -0
  74. package/lib/ReactWithAddons.js +41 -0
  75. package/lib/SelectEventPlugin.js +217 -0
  76. package/lib/SimpleEventPlugin.js +365 -0
  77. package/lib/SyntheticClipboardEvent.js +45 -0
  78. package/lib/SyntheticCompositionEvent.js +51 -0
  79. package/lib/SyntheticEvent.js +163 -0
  80. package/lib/SyntheticFocusEvent.js +44 -0
  81. package/lib/SyntheticKeyboardEvent.js +56 -0
  82. package/lib/SyntheticMouseEvent.js +85 -0
  83. package/lib/SyntheticTouchEvent.js +50 -0
  84. package/lib/SyntheticUIEvent.js +45 -0
  85. package/lib/SyntheticWheelEvent.js +63 -0
  86. package/lib/Transaction.js +251 -0
  87. package/lib/ViewportMetrics.js +37 -0
  88. package/lib/accumulate.js +54 -0
  89. package/lib/adler32.js +39 -0
  90. package/lib/containsNode.js +49 -0
  91. package/lib/copyProperties.js +54 -0
  92. package/lib/createArrayFrom.js +94 -0
  93. package/lib/createNodesFromMarkup.js +93 -0
  94. package/lib/createObjectFrom.js +61 -0
  95. package/lib/cx.js +44 -0
  96. package/lib/dangerousStyleValue.js +57 -0
  97. package/lib/emptyFunction.js +43 -0
  98. package/lib/escapeTextForBrowser.js +47 -0
  99. package/lib/ex.js +49 -0
  100. package/lib/filterAttributes.js +45 -0
  101. package/lib/flattenChildren.js +54 -0
  102. package/lib/forEachAccumulated.js +36 -0
  103. package/lib/ge.js +76 -0
  104. package/lib/getActiveElement.js +33 -0
  105. package/lib/getEventTarget.js +36 -0
  106. package/lib/getMarkupWrap.js +108 -0
  107. package/lib/getNodeForCharacterOffset.js +80 -0
  108. package/lib/getReactRootElementInContainer.js +40 -0
  109. package/lib/getTextContentAccessor.js +40 -0
  110. package/lib/getUnboundedScrollPosition.js +45 -0
  111. package/lib/hyphenate.js +35 -0
  112. package/lib/invariant.js +54 -0
  113. package/lib/isEventSupported.js +74 -0
  114. package/lib/isNode.js +33 -0
  115. package/lib/isTextInputElement.js +49 -0
  116. package/lib/isTextNode.js +30 -0
  117. package/lib/joinClasses.js +44 -0
  118. package/lib/keyMirror.js +58 -0
  119. package/lib/keyOf.js +41 -0
  120. package/lib/memoizeStringOnly.js +39 -0
  121. package/lib/merge.js +37 -0
  122. package/lib/mergeHelpers.js +137 -0
  123. package/lib/mergeInto.js +45 -0
  124. package/lib/mixInto.js +34 -0
  125. package/lib/mutateHTMLNodeWithMarkup.js +100 -0
  126. package/lib/objMap.js +47 -0
  127. package/lib/objMapKeyVal.js +47 -0
  128. package/lib/performanceNow.js +42 -0
  129. package/lib/shallowEqual.js +49 -0
  130. package/lib/traverseAllChildren.js +127 -0
  131. package/package.json +33 -31
  132. package/react.js +4 -0
  133. package/.npmignore +0 -7
  134. package/.travis.yml +0 -7
  135. package/Jakefile.js +0 -39
  136. package/LICENSE +0 -19
  137. package/browser-test/dist.html +0 -90
  138. package/browser-test/index.html +0 -86
  139. package/browser-test/min.html +0 -90
  140. package/dist/react.js +0 -3141
  141. package/dist/react.min.js +0 -22
  142. package/doc/advanced.md +0 -175
  143. package/doc/color-def.graffle +0 -938
  144. package/doc/color-def.png +0 -0
  145. package/doc/simple.dot +0 -25
  146. package/doc/simple.png +0 -0
  147. package/examples/longer-example.js +0 -41
  148. package/examples/simple.js +0 -45
  149. package/examples/using-ast-directly.js +0 -30
  150. package/examples/using-events1.js +0 -79
  151. package/examples/using-log-events.js +0 -43
  152. package/lib/base-task.js +0 -120
  153. package/lib/cb-task.js +0 -84
  154. package/lib/core.js +0 -138
  155. package/lib/dsl.js +0 -138
  156. package/lib/error.js +0 -55
  157. package/lib/event-collector.js +0 -81
  158. package/lib/event-manager.js +0 -89
  159. package/lib/eventemitter.js +0 -20
  160. package/lib/finalcb-first-task.js +0 -68
  161. package/lib/finalcb-task.js +0 -65
  162. package/lib/id.js +0 -22
  163. package/lib/input-parser.js +0 -56
  164. package/lib/log-events.js +0 -101
  165. package/lib/parse.js +0 -41
  166. package/lib/promise-resolve.js +0 -50
  167. package/lib/promise-task.js +0 -93
  168. package/lib/react.js +0 -59
  169. package/lib/ret-task.js +0 -71
  170. package/lib/sprintf.js +0 -18
  171. package/lib/status.js +0 -14
  172. package/lib/task.js +0 -251
  173. package/lib/track-tasks.js +0 -74
  174. package/lib/validate.js +0 -159
  175. package/lib/vcon.js +0 -113
  176. package/lib/when-task.js +0 -84
  177. package/src/dist.build.requirejs +0 -20
  178. package/test/ast.mocha.js +0 -136
  179. package/test/cb-task.mocha.js +0 -220
  180. package/test/core-deferred.mocha.js +0 -143
  181. package/test/core-when.mocha.js +0 -96
  182. package/test/core.mocha.js +0 -589
  183. package/test/dsl.mocha.js +0 -352
  184. package/test/event-manager.mocha.js +0 -119
  185. package/test/exec-options.mocha.js +0 -48
  186. package/test/finalcb-task.mocha.js +0 -58
  187. package/test/input-parser.mocha.js +0 -86
  188. package/test/log-events.mocha.js +0 -88
  189. package/test/mocha.opts +0 -2
  190. package/test/module-use.mocha.js +0 -164
  191. package/test/promise-auto-resolve.mocha.js +0 -68
  192. package/test/ret-task.mocha.js +0 -220
  193. package/test/task.mocha.js +0 -42
  194. package/test/validate-cb-task.mocha.js +0 -100
  195. package/test/validate-ret-task.mocha.js +0 -110
  196. package/test/validate.mocha.js +0 -324
  197. package/test/vcon.mocha.js +0 -193
  198. package/vendor/chai/chai.js +0 -4251
  199. package/vendor/jquery/jquery-1.7.1.js +0 -9266
  200. package/vendor/jquery/jquery-1.7.1.min.js +0 -4
  201. package/vendor/node/util.js +0 -531
  202. package/vendor/requirejs/require.js +0 -2045
  203. package/vendor/requirejs/require.min.js +0 -36
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Copyright 2013 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 DOMPropertyOperations
17
+ * @typechecks static-only
18
+ */
19
+
20
+ "use strict";
21
+
22
+ var DOMProperty = require("./DOMProperty");
23
+
24
+ var escapeTextForBrowser = require("./escapeTextForBrowser");
25
+ var memoizeStringOnly = require("./memoizeStringOnly");
26
+
27
+ function shouldIgnoreValue(name, value) {
28
+ return value == null ||
29
+ DOMProperty.hasBooleanValue[name] && !value ||
30
+ DOMProperty.hasPositiveNumericValue[name] && (isNaN(value) || value < 1);
31
+ }
32
+
33
+ var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
34
+ return escapeTextForBrowser(name) + '="';
35
+ });
36
+
37
+ if ("production" !== process.env.NODE_ENV) {
38
+ var reactProps = {
39
+ __owner__: true,
40
+ children: true,
41
+ dangerouslySetInnerHTML: true,
42
+ key: true,
43
+ ref: true
44
+ };
45
+ var warnedProperties = {};
46
+
47
+ var warnUnknownProperty = function(name) {
48
+ if (reactProps[name] || warnedProperties[name]) {
49
+ return;
50
+ }
51
+
52
+ warnedProperties[name] = true;
53
+ var lowerCasedName = name.toLowerCase();
54
+
55
+ // data-* attributes should be lowercase; suggest the lowercase version
56
+ var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ?
57
+ lowerCasedName : DOMProperty.getPossibleStandardName[lowerCasedName];
58
+
59
+ // For now, only warn when we have a suggested correction. This prevents
60
+ // logging too much when using transferPropsTo.
61
+ if (standardName != null) {
62
+ console.warn(
63
+ 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
64
+ );
65
+ }
66
+
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Operations for dealing with DOM properties.
72
+ */
73
+ var DOMPropertyOperations = {
74
+
75
+ /**
76
+ * Creates markup for a property.
77
+ *
78
+ * @param {string} name
79
+ * @param {*} value
80
+ * @return {?string} Markup string, or null if the property was invalid.
81
+ */
82
+ createMarkupForProperty: function(name, value) {
83
+ if (DOMProperty.isStandardName[name]) {
84
+ if (shouldIgnoreValue(name, value)) {
85
+ return '';
86
+ }
87
+ var attributeName = DOMProperty.getAttributeName[name];
88
+ return processAttributeNameAndPrefix(attributeName) +
89
+ escapeTextForBrowser(value) + '"';
90
+ } else if (DOMProperty.isCustomAttribute(name)) {
91
+ if (value == null) {
92
+ return '';
93
+ }
94
+ return processAttributeNameAndPrefix(name) +
95
+ escapeTextForBrowser(value) + '"';
96
+ } else if ("production" !== process.env.NODE_ENV) {
97
+ warnUnknownProperty(name);
98
+ }
99
+ return null;
100
+ },
101
+
102
+ /**
103
+ * Sets the value for a property on a node.
104
+ *
105
+ * @param {DOMElement} node
106
+ * @param {string} name
107
+ * @param {*} value
108
+ */
109
+ setValueForProperty: function(node, name, value) {
110
+ if (DOMProperty.isStandardName[name]) {
111
+ var mutationMethod = DOMProperty.getMutationMethod[name];
112
+ if (mutationMethod) {
113
+ mutationMethod(node, value);
114
+ } else if (shouldIgnoreValue(name, value)) {
115
+ this.deleteValueForProperty(node, name);
116
+ } else if (DOMProperty.mustUseAttribute[name]) {
117
+ node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
118
+ } else {
119
+ var propName = DOMProperty.getPropertyName[name];
120
+ if (!DOMProperty.hasSideEffects[name] || node[propName] !== value) {
121
+ node[propName] = value;
122
+ }
123
+ }
124
+ } else if (DOMProperty.isCustomAttribute(name)) {
125
+ if (value == null) {
126
+ node.removeAttribute(DOMProperty.getAttributeName[name]);
127
+ } else {
128
+ node.setAttribute(name, '' + value);
129
+ }
130
+ } else if ("production" !== process.env.NODE_ENV) {
131
+ warnUnknownProperty(name);
132
+ }
133
+ },
134
+
135
+ /**
136
+ * Deletes the value for a property on a node.
137
+ *
138
+ * @param {DOMElement} node
139
+ * @param {string} name
140
+ */
141
+ deleteValueForProperty: function(node, name) {
142
+ if (DOMProperty.isStandardName[name]) {
143
+ var mutationMethod = DOMProperty.getMutationMethod[name];
144
+ if (mutationMethod) {
145
+ mutationMethod(node, undefined);
146
+ } else if (DOMProperty.mustUseAttribute[name]) {
147
+ node.removeAttribute(DOMProperty.getAttributeName[name]);
148
+ } else {
149
+ var propName = DOMProperty.getPropertyName[name];
150
+ var defaultValue = DOMProperty.getDefaultValueForProperty(
151
+ node.nodeName,
152
+ name
153
+ );
154
+ if (!DOMProperty.hasSideEffects[name] ||
155
+ node[propName] !== defaultValue) {
156
+ node[propName] = defaultValue;
157
+ }
158
+ }
159
+ } else if (DOMProperty.isCustomAttribute(name)) {
160
+ node.removeAttribute(name);
161
+ } else if ("production" !== process.env.NODE_ENV) {
162
+ warnUnknownProperty(name);
163
+ }
164
+ }
165
+
166
+ };
167
+
168
+ module.exports = DOMPropertyOperations;
package/lib/Danger.js ADDED
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Copyright 2013 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 Danger
17
+ * @typechecks static-only
18
+ */
19
+
20
+ /*jslint evil: true, sub: true */
21
+
22
+ "use strict";
23
+
24
+ var ExecutionEnvironment = require("./ExecutionEnvironment");
25
+
26
+ var createNodesFromMarkup = require("./createNodesFromMarkup");
27
+ var emptyFunction = require("./emptyFunction");
28
+ var getMarkupWrap = require("./getMarkupWrap");
29
+ var invariant = require("./invariant");
30
+ var mutateHTMLNodeWithMarkup = require("./mutateHTMLNodeWithMarkup");
31
+
32
+ var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
33
+ var RESULT_INDEX_ATTR = 'data-danger-index';
34
+
35
+ /**
36
+ * Extracts the `nodeName` from a string of markup.
37
+ *
38
+ * NOTE: Extracting the `nodeName` does not require a regular expression match
39
+ * because we make assumptions about React-generated markup (i.e. there are no
40
+ * spaces surrounding the opening tag and there is at least one attribute).
41
+ *
42
+ * @param {string} markup String of markup.
43
+ * @return {string} Node name of the supplied markup.
44
+ * @see http://jsperf.com/extract-nodename
45
+ */
46
+ function getNodeName(markup) {
47
+ return markup.substring(1, markup.indexOf(' '));
48
+ }
49
+
50
+ var Danger = {
51
+
52
+ /**
53
+ * Renders markup into an array of nodes. The markup is expected to render
54
+ * into a list of root nodes. Also, the length of `resultList` and
55
+ * `markupList` should be the same.
56
+ *
57
+ * @param {array<string>} markupList List of markup strings to render.
58
+ * @return {array<DOMElement>} List of rendered nodes.
59
+ * @internal
60
+ */
61
+ dangerouslyRenderMarkup: function(markupList) {
62
+ ("production" !== process.env.NODE_ENV ? invariant(
63
+ ExecutionEnvironment.canUseDOM,
64
+ 'dangerouslyRenderMarkup(...): Cannot render markup in a Worker ' +
65
+ 'thread. This is likely a bug in the framework. Please report ' +
66
+ 'immediately.'
67
+ ) : invariant(ExecutionEnvironment.canUseDOM));
68
+ var nodeName;
69
+ var markupByNodeName = {};
70
+ // Group markup by `nodeName` if a wrap is necessary, else by '*'.
71
+ for (var i = 0; i < markupList.length; i++) {
72
+ ("production" !== process.env.NODE_ENV ? invariant(
73
+ markupList[i],
74
+ 'dangerouslyRenderMarkup(...): Missing markup.'
75
+ ) : invariant(markupList[i]));
76
+ nodeName = getNodeName(markupList[i]);
77
+ nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
78
+ markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
79
+ markupByNodeName[nodeName][i] = markupList[i];
80
+ }
81
+ var resultList = [];
82
+ var resultListAssignmentCount = 0;
83
+ for (nodeName in markupByNodeName) {
84
+ if (!markupByNodeName.hasOwnProperty(nodeName)) {
85
+ continue;
86
+ }
87
+ var markupListByNodeName = markupByNodeName[nodeName];
88
+
89
+ // This for-in loop skips the holes of the sparse array. The order of
90
+ // iteration should follow the order of assignment, which happens to match
91
+ // numerical index order, but we don't rely on that.
92
+ for (var resultIndex in markupListByNodeName) {
93
+ if (markupListByNodeName.hasOwnProperty(resultIndex)) {
94
+ var markup = markupListByNodeName[resultIndex];
95
+
96
+ // Push the requested markup with an additional RESULT_INDEX_ATTR
97
+ // attribute. If the markup does not start with a < character, it
98
+ // will be discarded below (with an appropriate console.error).
99
+ markupListByNodeName[resultIndex] = markup.replace(
100
+ OPEN_TAG_NAME_EXP,
101
+ // This index will be parsed back out below.
102
+ '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
103
+ );
104
+ }
105
+ }
106
+
107
+ // Render each group of markup with similar wrapping `nodeName`.
108
+ var renderNodes = createNodesFromMarkup(
109
+ markupListByNodeName.join(''),
110
+ emptyFunction // Do nothing special with <script> tags.
111
+ );
112
+
113
+ for (i = 0; i < renderNodes.length; ++i) {
114
+ var renderNode = renderNodes[i];
115
+ if (renderNode.hasAttribute &&
116
+ renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
117
+
118
+ resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
119
+ renderNode.removeAttribute(RESULT_INDEX_ATTR);
120
+
121
+ ("production" !== process.env.NODE_ENV ? invariant(
122
+ !resultList.hasOwnProperty(resultIndex),
123
+ 'Danger: Assigning to an already-occupied result index.'
124
+ ) : invariant(!resultList.hasOwnProperty(resultIndex)));
125
+
126
+ resultList[resultIndex] = renderNode;
127
+
128
+ // This should match resultList.length and markupList.length when
129
+ // we're done.
130
+ resultListAssignmentCount += 1;
131
+
132
+ } else if ("production" !== process.env.NODE_ENV) {
133
+ console.error(
134
+ "Danger: Discarding unexpected node:",
135
+ renderNode
136
+ );
137
+ }
138
+ }
139
+ }
140
+
141
+ // Although resultList was populated out of order, it should now be a dense
142
+ // array.
143
+ ("production" !== process.env.NODE_ENV ? invariant(
144
+ resultListAssignmentCount === resultList.length,
145
+ 'Danger: Did not assign to every index of resultList.'
146
+ ) : invariant(resultListAssignmentCount === resultList.length));
147
+
148
+ ("production" !== process.env.NODE_ENV ? invariant(
149
+ resultList.length === markupList.length,
150
+ 'Danger: Expected markup to render %s nodes, but rendered %s.',
151
+ markupList.length,
152
+ resultList.length
153
+ ) : invariant(resultList.length === markupList.length));
154
+
155
+ return resultList;
156
+ },
157
+
158
+ /**
159
+ * Replaces a node with a string of markup at its current position within its
160
+ * parent. The markup must render into a single root node.
161
+ *
162
+ * @param {DOMElement} oldChild Child node to replace.
163
+ * @param {string} markup Markup to render in place of the child node.
164
+ * @internal
165
+ */
166
+ dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
167
+ ("production" !== process.env.NODE_ENV ? invariant(
168
+ ExecutionEnvironment.canUseDOM,
169
+ 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
170
+ 'worker thread. This is likely a bug in the framework. Please report ' +
171
+ 'immediately.'
172
+ ) : invariant(ExecutionEnvironment.canUseDOM));
173
+ ("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
174
+ // createNodesFromMarkup() won't work if the markup is rooted by <html>
175
+ // since it has special semantic meaning. So we use an alternatie strategy.
176
+ if (oldChild.tagName.toLowerCase() === 'html') {
177
+ mutateHTMLNodeWithMarkup(oldChild, markup);
178
+ return;
179
+ }
180
+ var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
181
+ oldChild.parentNode.replaceChild(newChild, oldChild);
182
+ }
183
+
184
+ };
185
+
186
+ module.exports = Danger;
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Copyright 2013 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 DefaultDOMPropertyConfig
17
+ */
18
+
19
+ /*jslint bitwise: true*/
20
+
21
+ "use strict";
22
+
23
+ var DOMProperty = require("./DOMProperty");
24
+
25
+ var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
26
+ var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
27
+ var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
28
+ var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
29
+ var HAS_POSITIVE_NUMERIC_VALUE =
30
+ DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
31
+
32
+ var DefaultDOMPropertyConfig = {
33
+ isCustomAttribute: RegExp.prototype.test.bind(
34
+ /^(data|aria)-[a-z_][a-z\d_.\-]*$/
35
+ ),
36
+ Properties: {
37
+ /**
38
+ * Standard Properties
39
+ */
40
+ accept: null,
41
+ accessKey: null,
42
+ action: null,
43
+ allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
44
+ allowTransparency: MUST_USE_ATTRIBUTE,
45
+ alt: null,
46
+ async: HAS_BOOLEAN_VALUE,
47
+ autoComplete: null,
48
+ autoFocus: HAS_BOOLEAN_VALUE,
49
+ autoPlay: HAS_BOOLEAN_VALUE,
50
+ cellPadding: null,
51
+ cellSpacing: null,
52
+ charSet: MUST_USE_ATTRIBUTE,
53
+ checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
54
+ className: MUST_USE_PROPERTY,
55
+ cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
56
+ colSpan: null,
57
+ content: null,
58
+ contentEditable: null,
59
+ contextMenu: MUST_USE_ATTRIBUTE,
60
+ controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
61
+ data: null, // For `<object />` acts as `src`.
62
+ dateTime: MUST_USE_ATTRIBUTE,
63
+ defer: HAS_BOOLEAN_VALUE,
64
+ dir: null,
65
+ disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
66
+ draggable: null,
67
+ encType: null,
68
+ form: MUST_USE_ATTRIBUTE,
69
+ frameBorder: MUST_USE_ATTRIBUTE,
70
+ height: MUST_USE_ATTRIBUTE,
71
+ hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
72
+ href: null,
73
+ htmlFor: null,
74
+ httpEquiv: null,
75
+ icon: null,
76
+ id: MUST_USE_PROPERTY,
77
+ label: null,
78
+ lang: null,
79
+ list: null,
80
+ loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
81
+ max: null,
82
+ maxLength: MUST_USE_ATTRIBUTE,
83
+ method: null,
84
+ min: null,
85
+ multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
86
+ name: null,
87
+ pattern: null,
88
+ placeholder: null,
89
+ poster: null,
90
+ preload: null,
91
+ radioGroup: null,
92
+ readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
93
+ rel: null,
94
+ required: HAS_BOOLEAN_VALUE,
95
+ role: MUST_USE_ATTRIBUTE,
96
+ rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
97
+ rowSpan: null,
98
+ scrollLeft: MUST_USE_PROPERTY,
99
+ scrollTop: MUST_USE_PROPERTY,
100
+ selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
101
+ size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
102
+ spellCheck: null,
103
+ src: null,
104
+ step: null,
105
+ style: null,
106
+ tabIndex: null,
107
+ target: null,
108
+ title: null,
109
+ type: null,
110
+ value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
111
+ width: MUST_USE_ATTRIBUTE,
112
+ wmode: MUST_USE_ATTRIBUTE,
113
+
114
+ /**
115
+ * Non-standard Properties
116
+ */
117
+ autoCapitalize: null, // Supported in Mobile Safari for keyboard hints
118
+ autoCorrect: null, // Supported in Mobile Safari for keyboard hints
119
+
120
+ /**
121
+ * SVG Properties
122
+ */
123
+ cx: MUST_USE_ATTRIBUTE,
124
+ cy: MUST_USE_ATTRIBUTE,
125
+ d: MUST_USE_ATTRIBUTE,
126
+ fill: MUST_USE_ATTRIBUTE,
127
+ fx: MUST_USE_ATTRIBUTE,
128
+ fy: MUST_USE_ATTRIBUTE,
129
+ gradientTransform: MUST_USE_ATTRIBUTE,
130
+ gradientUnits: MUST_USE_ATTRIBUTE,
131
+ offset: MUST_USE_ATTRIBUTE,
132
+ points: MUST_USE_ATTRIBUTE,
133
+ r: MUST_USE_ATTRIBUTE,
134
+ rx: MUST_USE_ATTRIBUTE,
135
+ ry: MUST_USE_ATTRIBUTE,
136
+ spreadMethod: MUST_USE_ATTRIBUTE,
137
+ stopColor: MUST_USE_ATTRIBUTE,
138
+ stopOpacity: MUST_USE_ATTRIBUTE,
139
+ stroke: MUST_USE_ATTRIBUTE,
140
+ strokeLinecap: MUST_USE_ATTRIBUTE,
141
+ strokeWidth: MUST_USE_ATTRIBUTE,
142
+ transform: MUST_USE_ATTRIBUTE,
143
+ version: MUST_USE_ATTRIBUTE,
144
+ viewBox: MUST_USE_ATTRIBUTE,
145
+ x1: MUST_USE_ATTRIBUTE,
146
+ x2: MUST_USE_ATTRIBUTE,
147
+ x: MUST_USE_ATTRIBUTE,
148
+ y1: MUST_USE_ATTRIBUTE,
149
+ y2: MUST_USE_ATTRIBUTE,
150
+ y: MUST_USE_ATTRIBUTE
151
+ },
152
+ DOMAttributeNames: {
153
+ className: 'class',
154
+ gradientTransform: 'gradientTransform',
155
+ gradientUnits: 'gradientUnits',
156
+ htmlFor: 'for',
157
+ spreadMethod: 'spreadMethod',
158
+ stopColor: 'stop-color',
159
+ stopOpacity: 'stop-opacity',
160
+ strokeLinecap: 'stroke-linecap',
161
+ strokeWidth: 'stroke-width',
162
+ viewBox: 'viewBox'
163
+ },
164
+ DOMPropertyNames: {
165
+ autoCapitalize: 'autocapitalize',
166
+ autoComplete: 'autocomplete',
167
+ autoCorrect: 'autocorrect',
168
+ autoFocus: 'autofocus',
169
+ autoPlay: 'autoplay',
170
+ encType: 'enctype',
171
+ radioGroup: 'radiogroup',
172
+ spellCheck: 'spellcheck'
173
+ },
174
+ DOMMutationMethods: {
175
+ /**
176
+ * Setting `className` to null may cause it to be set to the string "null".
177
+ *
178
+ * @param {DOMElement} node
179
+ * @param {*} value
180
+ */
181
+ className: function(node, value) {
182
+ node.className = value || '';
183
+ }
184
+ }
185
+ };
186
+
187
+ module.exports = DefaultDOMPropertyConfig;