@samitouri / QOS-React / commits / e34e8974db

Remove markup related paths

Sebastian Markbage committed Nov 15, 2016 at 17:42 UTC e34e8974db85e98e735a73a65f01e49b35e6f414
1 file changed +40 -171
src/renderers/dom/fiber/ReactDOMFiberComponent.js
+40 -171
@@ -495,127 +495,6 @@ function isCustomComponent(tagName, props) {
495 return tagName.indexOf('-') >= 0 || props.is != null;
496 }
497
498 -
499 -/**
500 - * Creates markup for the open tag and all attributes.
501 - *
502 - * This method has side effects because events get registered.
503 - *
504 - * Iterating over object properties is faster than iterating over arrays.
505 - * @see http://jsperf.com/obj-vs-arr-iteration
506 - *
507 - * @private
508 - * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
509 - * @param {object} props
510 - * @return {string} Markup of opening tag.
511 - */
512 -function createOpenTagMarkupAndPutListeners(workInProgress, transaction, props) {
513 - var ret = '<' + workInProgress._currentElement.type;
514 -
515 - for (var propKey in props) {
516 - if (!props.hasOwnProperty(propKey)) {
517 - continue;
518 - }
519 - var propValue = props[propKey];
520 - if (propValue == null) {
521 - continue;
522 - }
523 - if (registrationNameModules.hasOwnProperty(propKey)) {
524 - if (propValue) {
525 - enqueuePutListener(workInProgress, propKey, propValue, transaction);
526 - }
527 - } else {
528 - if (propKey === STYLE) {
529 - if (propValue) {
530 - if (__DEV__) {
531 - // See `_updateDOMProperties`. style block
532 - workInProgress._previousStyle = propValue;
533 - }
534 - propValue = workInProgress._previousStyleCopy = Object.assign({}, props.style);
535 - }
536 - propValue = CSSPropertyOperations.createMarkupForStyles(propValue, workInProgress);
537 - }
538 - var markup = null;
539 - if (workInProgress._tag != null && isCustomComponent(workInProgress._tag, props)) {
540 - if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
541 - markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
542 - }
543 - } else {
544 - markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
545 - }
546 - if (markup) {
547 - ret += ' ' + markup;
548 - }
549 - }
550 - }
551 -
552 - // For static pages, no need to put React ID and checksum. Saves lots of
553 - // bytes.
554 - if (transaction.renderToStaticMarkup) {
555 - return ret;
556 - }
557 -
558 - if (!workInProgress._hostParent) {
559 - ret += ' ' + DOMPropertyOperations.createMarkupForRoot();
560 - }
561 - ret += ' ' + DOMPropertyOperations.createMarkupForID(workInProgress._domID);
562 - return ret;
563 -}
564 -
565 -/**
566 - * Creates markup for the content between the tags.
567 - *
568 - * @private
569 - * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
570 - * @param {object} props
571 - * @param {object} context
572 - * @return {string} Content markup.
573 - */
574 -function createContentMarkup(workInProgress, transaction, props, context) {
575 - var ret = '';
576 -
577 - // Intentional use of != to avoid catching zero/false.
578 - var innerHTML = props.dangerouslySetInnerHTML;
579 - if (innerHTML != null) {
580 - if (innerHTML.__html != null) {
581 - ret = innerHTML.__html;
582 - }
583 - } else {
584 - var contentToUse =
585 - CONTENT_TYPES[typeof props.children] ? props.children : null;
586 - var childrenToUse = contentToUse != null ? null : props.children;
587 - if (contentToUse != null) {
588 - // TODO: Validate that text is allowed as a child of this node
589 - ret = escapeTextContentForBrowser(contentToUse);
590 - if (__DEV__) {
591 - setAndValidateContentChildDev.call(workInProgress, contentToUse);
592 - }
593 - } else if (childrenToUse != null) {
594 - var mountImages = workInProgress.mountChildren(
595 - childrenToUse,
596 - transaction,
597 - context
598 - );
599 - ret = mountImages.join('');
600 - }
601 - }
602 - if (newlineEatingTags[workInProgress._tag] && ret.charAt(0) === '\n') {
603 - // text/html ignores the first character in these tags if it's a newline
604 - // Prefer to break application/xml over text/html (for now) by adding
605 - // a newline specifically to get eaten by the parser. (Alternately for
606 - // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
607 - // \r is normalized out by HTMLTextAreaElement#value.)
608 - // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
609 - // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
610 - // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
611 - // See: Parsing of "textarea" "listing" and "pre" elements
612 - // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
613 - return '\n' + ret;
614 - } else {
615 - return ret;
616 - }
617 -}
618 -
498 function createInitialChildren(workInProgress, transaction, props, context, lazyTree) {
499 // Intentional use of != to avoid catching zero/false.
500 var innerHTML = props.dangerouslySetInnerHTML;
@@ -981,60 +860,50 @@ var ReactDOMFiberComponent = {
860
861 var mountImage;
862 var type = workInProgress._currentElement.type;
984 - if (transaction.useCreateElement) {
985 - var ownerDocument = hostContainerInfo._ownerDocument;
986 - var el;
987 - if (namespaceURI === DOMNamespaces.html) {
988 - if (workInProgress._tag === 'script') {
989 - // Create the script via .innerHTML so its "parser-inserted" flag is
990 - // set to true and it does not execute
991 - var div = ownerDocument.createElement('div');
992 - div.innerHTML = `<${type}></${type}>`;
993 - el = div.removeChild(div.firstChild);
994 - } else if (props.is) {
995 - el = ownerDocument.createElement(type, props.is);
996 - } else {
997 - // Separate else branch instead of using `props.is || undefined` above becuase of a Firefox bug.
998 - // See discussion in https://github.com/facebook/react/pull/6896
999 - // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
1000 - el = ownerDocument.createElement(type);
1001 - }
863 + var ownerDocument = hostContainerInfo._ownerDocument;
864 + var el;
865 + if (namespaceURI === DOMNamespaces.html) {
866 + if (workInProgress._tag === 'script') {
867 + // Create the script via .innerHTML so its "parser-inserted" flag is
868 + // set to true and it does not execute
869 + var div = ownerDocument.createElement('div');
870 + div.innerHTML = `<${type}></${type}>`;
871 + el = div.removeChild(div.firstChild);
872 + } else if (props.is) {
873 + el = ownerDocument.createElement(type, props.is);
874 } else {
1003 - el = ownerDocument.createElementNS(
1004 - namespaceURI,
1005 - type
1006 - );
1007 - }
1008 - var isCustomComponentTag = isCustomComponent(workInProgress._tag, props);
1009 - if (__DEV__ && isCustomComponentTag && !didWarnShadyDOM && el.shadyRoot) {
1010 - var owner = workInProgress._currentElement._owner;
1011 - var name = owner && owner.getName() || 'A component';
1012 - warning(
1013 - false,
1014 - '%s is using shady DOM. Using shady DOM with React can ' +
1015 - 'cause things to break subtly.',
1016 - name
1017 - );
1018 - didWarnShadyDOM = true;
1019 - }
1020 - ReactDOMComponentTree.precacheNode(workInProgress, el);
1021 - workInProgress._flags |= Flags.hasCachedChildNodes;
1022 - if (!workInProgress._hostParent) {
1023 - DOMPropertyOperations.setAttributeForRoot(el);
875 + // Separate else branch instead of using `props.is || undefined` above becuase of a Firefox bug.
876 + // See discussion in https://github.com/facebook/react/pull/6896
877 + // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
878 + el = ownerDocument.createElement(type);
879 }
1025 - updateDOMProperties(workInProgress, null, props, transaction, isCustomComponentTag);
1026 - var lazyTree = DOMLazyTree(el);
1027 - createInitialChildren(workInProgress, transaction, props, context, lazyTree);
1028 - mountImage = lazyTree;
880 } else {
1030 - var tagOpen = createOpenTagMarkupAndPutListeners(workInProgress, transaction, props);
1031 - var tagContent = createContentMarkup(workInProgress, transaction, props, context);
1032 - if (!tagContent && omittedCloseTags[workInProgress._tag]) {
1033 - mountImage = tagOpen + '/>';
1034 - } else {
1035 - mountImage = tagOpen + '>' + tagContent + '</' + type + '>';
1036 - }
881 + el = ownerDocument.createElementNS(
882 + namespaceURI,
883 + type
884 + );
885 + }
886 + var isCustomComponentTag = isCustomComponent(workInProgress._tag, props);
887 + if (__DEV__ && isCustomComponentTag && !didWarnShadyDOM && el.shadyRoot) {
888 + var owner = workInProgress._currentElement._owner;
889 + var name = owner && owner.getName() || 'A component';
890 + warning(
891 + false,
892 + '%s is using shady DOM. Using shady DOM with React can ' +
893 + 'cause things to break subtly.',
894 + name
895 + );
896 + didWarnShadyDOM = true;
897 + }
898 + ReactDOMComponentTree.precacheNode(workInProgress, el);
899 + workInProgress._flags |= Flags.hasCachedChildNodes;
900 + if (!workInProgress._hostParent) {
901 + DOMPropertyOperations.setAttributeForRoot(el);
902 }
903 + updateDOMProperties(workInProgress, null, props, transaction, isCustomComponentTag);
904 + var lazyTree = DOMLazyTree(el);
905 + createInitialChildren(workInProgress, transaction, props, context, lazyTree);
906 + mountImage = lazyTree;
907
908 switch (workInProgress._tag) {
909 case 'input':