Move small utility modules out of ReactDOM(Fiber)?Component (#9658)
* Move small utility modules out of ReactDOM(Fiber)?Component These are all going to be needed in the server renderer, so I'm moving them out now so I can use them from in there. * Fix `didWarnShadyDOM = false;` line
Tom Occhino committed
May 10, 2017 at 22:01 UTC
ffcbb0bfc2e902b0ddb0604bf19c846284127d8f
5 files changed
+86
-72
src/renderers/dom/fiber/ReactDOMFiberComponent.js
+3
-35
@@ -26,10 +26,12 @@ var {getCurrentFiberOwnerName} = require('ReactDebugCurrentFiber');
26
var {DOCUMENT_FRAGMENT_NODE} = require('HTMLNodeType');
27
28
var emptyFunction = require('fbjs/lib/emptyFunction');
29
+var inputValueTracking = require('inputValueTracking');
30
var invariant = require('fbjs/lib/invariant');
31
+var isCustomComponent = require('isCustomComponent');
32
var setInnerHTML = require('setInnerHTML');
33
var setTextContent = require('setTextContent');
32
-var inputValueTracking = require('inputValueTracking');
34
+var voidElementTags = require('voidElementTags');
35
var warning = require('fbjs/lib/warning');
36
37
if (__DEV__) {
@@ -237,40 +239,6 @@ function trapBubbledEventsLocal(node: Element, tag: string) {
239
}
240
}
241
240
-// For HTML, certain tags should omit their close tag. We keep a whitelist for
241
-// those special-case tags.
242
-
243
-var omittedCloseTags = {
244
- area: true,
245
- base: true,
246
- br: true,
247
- col: true,
248
- embed: true,
249
- hr: true,
250
- img: true,
251
- input: true,
252
- keygen: true,
253
- link: true,
254
- meta: true,
255
- param: true,
256
- source: true,
257
- track: true,
258
- wbr: true,
259
- // NOTE: menuitem's close tag should be omitted, but that causes problems.
260
-};
261
-
262
-// For HTML, certain tags cannot have children. This has the same purpose as
263
-// `omittedCloseTags` except that `menuitem` should still have its closing tag.
264
-
265
-var voidElementTags = {
266
- menuitem: true,
267
- ...omittedCloseTags,
268
-};
269
-
270
-function isCustomComponent(tagName, props) {
271
- return tagName.indexOf('-') >= 0 || props.is != null;
272
-}
273
-
242
function setInitialDOMProperties(
243
domElement: Element,
244
rootContainerElement: Element,
src/renderers/dom/shared/utils/isCustomComponent.js
new
+18
@@ -0,0 +1,18 @@
1
+/**
2
+ * Copyright 2013-present, 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 isCustomComponent
10
+ */
11
+
12
+'use strict';
13
+
14
+function isCustomComponent(tagName, props) {
15
+ return tagName.indexOf('-') >= 0 || props.is != null;
16
+}
17
+
18
+module.exports = isCustomComponent;
src/renderers/dom/shared/utils/omittedCloseTags.js
new
+36
@@ -0,0 +1,36 @@
1
+/**
2
+ * Copyright 2013-present, 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 omittedCloseTags
10
+ */
11
+
12
+'use strict';
13
+
14
+// For HTML, certain tags should omit their close tag. We keep a whitelist for
15
+// those special-case tags.
16
+
17
+var omittedCloseTags = {
18
+ area: true,
19
+ base: true,
20
+ br: true,
21
+ col: true,
22
+ embed: true,
23
+ hr: true,
24
+ img: true,
25
+ input: true,
26
+ keygen: true,
27
+ link: true,
28
+ meta: true,
29
+ param: true,
30
+ source: true,
31
+ track: true,
32
+ wbr: true,
33
+ // NOTE: menuitem's close tag should be omitted, but that causes problems.
34
+};
35
+
36
+module.exports = omittedCloseTags;
src/renderers/dom/shared/utils/voidElementTags.js
new
+24
@@ -0,0 +1,24 @@
1
+/**
2
+ * Copyright 2013-present, 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 voidElementTags
10
+ */
11
+
12
+'use strict';
13
+
14
+var omittedCloseTags = require('omittedCloseTags');
15
+
16
+// For HTML, certain tags cannot have children. This has the same purpose as
17
+// `omittedCloseTags` except that `menuitem` should still have its closing tag.
18
+
19
+var voidElementTags = {
20
+ menuitem: true,
21
+ ...omittedCloseTags,
22
+};
23
+
24
+module.exports = voidElementTags;
src/renderers/dom/stack/client/ReactDOMComponent.js
+5
-37
@@ -32,10 +32,14 @@ var {DOCUMENT_FRAGMENT_NODE} = require('HTMLNodeType');
32
33
var emptyFunction = require('fbjs/lib/emptyFunction');
34
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
35
-var invariant = require('fbjs/lib/invariant');
35
var inputValueTracking = require('inputValueTracking');
36
+var invariant = require('fbjs/lib/invariant');
37
+var isCustomComponent = require('isCustomComponent');
38
+var omittedCloseTags = require('omittedCloseTags');
39
var validateDOMNesting = require('validateDOMNesting');
40
+var voidElementTags = require('voidElementTags');
41
var warning = require('fbjs/lib/warning');
42
+
43
var didWarnShadyDOM = false;
44
45
var Flags = ReactDOMComponentFlags;
@@ -312,44 +316,12 @@ function postUpdateSelectWrapper() {
316
ReactDOMSelect.postUpdateWrapper(this);
317
}
318
315
-// For HTML, certain tags should omit their close tag. We keep a whitelist for
316
-// those special-case tags.
317
-
318
-var omittedCloseTags = {
319
- area: true,
320
- base: true,
321
- br: true,
322
- col: true,
323
- embed: true,
324
- hr: true,
325
- img: true,
326
- input: true,
327
- keygen: true,
328
- link: true,
329
- meta: true,
330
- param: true,
331
- source: true,
332
- track: true,
333
- wbr: true,
334
- // NOTE: menuitem's close tag should be omitted, but that causes problems.
335
-};
336
-
319
var newlineEatingTags = {
320
listing: true,
321
pre: true,
322
textarea: true,
323
};
324
343
-// For HTML, certain tags cannot have children. This has the same purpose as
344
-// `omittedCloseTags` except that `menuitem` should still have its closing tag.
345
-
346
-var voidElementTags = Object.assign(
347
- {
348
- menuitem: true,
349
- },
350
- omittedCloseTags,
351
-);
352
-
325
// We accept any tag to be rendered but since this gets injected into arbitrary
326
// HTML, we want to make sure that it's a safe tag.
327
// http://www.w3.org/TR/REC-xml/#NT-Name
@@ -364,10 +336,6 @@ function validateDangerousTag(tag) {
336
}
337
}
338
367
-function isCustomComponent(tagName, props) {
368
- return tagName.indexOf('-') >= 0 || props.is != null;
369
-}
370
-
339
var globalIdCounter = 1;
340
341
/**