Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. diff --git a/src/renderers/dom/server/__tests__/ReactServerRendering-test.js b/src/renderers/dom/server/__tests__/ReactServerRendering-test.js
  2. index 1c37530..391ecbe 100644
  3. --- a/src/renderers/dom/server/__tests__/ReactServerRendering-test.js
  4. +++ b/src/renderers/dom/server/__tests__/ReactServerRendering-test.js
  5. @@ -123,6 +123,33 @@ describe('ReactServerRendering', function() {
  6. );
  7. });
  8.  
  9. + it('should not put React ID inside <noscript>s', function() {
  10. + class Component extends React.Component {
  11. + render() {
  12. + return <div>
  13. + <noscript><span>Shhh...</span></noscript>
  14. + <span>Hello!</span>
  15. + </div>;
  16. + }
  17. + }
  18. +
  19. + var response = ReactServerRendering.renderToString(
  20. + <Component />
  21. + );
  22. + expect(response).toMatch(
  23. + '<div ' + ROOT_ATTRIBUTE_NAME + '="" ' +
  24. + ID_ATTRIBUTE_NAME + '="[^"]+" ' +
  25. + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
  26. + '<noscript ' + ID_ATTRIBUTE_NAME + '="[^"]+">' +
  27. + '<span>Shhh...</span>' +
  28. + '</noscript>' +
  29. + '<span ' + ID_ATTRIBUTE_NAME + '="[^"]+">' +
  30. + 'Hello!' +
  31. + '</span>' +
  32. + '</div>'
  33. + );
  34. + });
  35. +
  36. it('should only execute certain lifecycle methods', function() {
  37. function runTest() {
  38. var lifecycle = [];
  39. diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js
  40. index 88ed489..0573d98 100644
  41. --- a/src/renderers/dom/shared/ReactDOMComponent.js
  42. +++ b/src/renderers/dom/shared/ReactDOMComponent.js
  43. @@ -524,7 +524,12 @@ ReactDOMComponent.Mixin = {
  44. context
  45. ) {
  46. this._rootNodeID = globalIdCounter++;
  47. - this._domID = hostContainerInfo._idCounter++;
  48. + // STOPSHIP TODO(william): Don't hack this on to context;
  49. + // figure out the right way to thread it through instead.
  50. + this._domID = hostContainerInfo._idCounter;
  51. + if (!context.__inNoscript) {
  52. + hostContainerInfo._idCounter++;
  53. + }
  54. this._hostParent = hostParent;
  55. this._hostContainerInfo = hostContainerInfo;
  56.  
  57. @@ -648,7 +653,14 @@ ReactDOMComponent.Mixin = {
  58. this._createInitialChildren(transaction, props, context, lazyTree);
  59. mountImage = lazyTree;
  60. } else {
  61. - var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
  62. + // STOPSHIP TODO(william): Don't hack this on to context;
  63. + // figure out the right way to thread it through instead.
  64. + var inNoscript = context.__inNoscript || false;
  65. + var tagOpen = this._createOpenTagMarkupAndPutListeners(
  66. + transaction, props, inNoscript);
  67. + if (this._tag === 'noscript') {
  68. + context = Object.assign({}, context, {__inNoscript: true});
  69. + }
  70. var tagContent = this._createContentMarkup(transaction, props, context);
  71. if (!tagContent && omittedCloseTags[this._tag]) {
  72. mountImage = tagOpen + '/>';
  73. @@ -721,9 +733,16 @@ ReactDOMComponent.Mixin = {
  74. * @private
  75. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  76. * @param {object} props
  77. + * @param {boolean} inNoscript true if one of our proper ancestors is
  78. + * a noscript tag, in which case we won't attach the react ID (see #7607)
  79. * @return {string} Markup of opening tag.
  80. */
  81. - _createOpenTagMarkupAndPutListeners: function(transaction, props) {
  82. + _createOpenTagMarkupAndPutListeners: function(
  83. + transaction,
  84. + props,
  85. + inNoscript
  86. + ) {
  87. + // TODO STOPSHIP strip this
  88. var ret = '<' + this._currentElement.type;
  89.  
  90. for (var propKey in props) {
  91. @@ -772,7 +791,9 @@ ReactDOMComponent.Mixin = {
  92. if (!this._hostParent) {
  93. ret += ' ' + DOMPropertyOperations.createMarkupForRoot();
  94. }
  95. - ret += ' ' + DOMPropertyOperations.createMarkupForID(this._domID);
  96. + if (!inNoscript) {
  97. + ret += ' ' + DOMPropertyOperations.createMarkupForID(this._domID);
  98. + }
  99. return ret;
  100. },
  101.  
  102. diff --git a/src/renderers/dom/shared/ReactDOMEmptyComponent.js b/src/renderers/dom/shared/ReactDOMEmptyComponent.js
  103. index 0a7b8c6..93603c2 100644
  104. --- a/src/renderers/dom/shared/ReactDOMEmptyComponent.js
  105. +++ b/src/renderers/dom/shared/ReactDOMEmptyComponent.js
  106. @@ -31,7 +31,12 @@ Object.assign(ReactDOMEmptyComponent.prototype, {
  107. hostContainerInfo,
  108. context
  109. ) {
  110. - var domID = hostContainerInfo._idCounter++;
  111. + // STOPSHIP TODO(william): Don't hack this on to context;
  112. + // figure out the right way to thread it through instead.
  113. + var domID = hostContainerInfo._idCounter;
  114. + if (!context.__inNoscript) {
  115. + hostContainerInfo._idCounter++;
  116. + }
  117. this._domID = domID;
  118. this._hostParent = hostParent;
  119. this._hostContainerInfo = hostContainerInfo;
  120. diff --git a/src/renderers/dom/shared/ReactDOMTextComponent.js b/src/renderers/dom/shared/ReactDOMTextComponent.js
  121. index 860bc33..bfd8f26 100644
  122. --- a/src/renderers/dom/shared/ReactDOMTextComponent.js
  123. +++ b/src/renderers/dom/shared/ReactDOMTextComponent.js
  124. @@ -79,7 +79,12 @@ Object.assign(ReactDOMTextComponent.prototype, {
  125. }
  126. }
  127.  
  128. - var domID = hostContainerInfo._idCounter++;
  129. + // STOPSHIP TODO(william): Don't hack this on to context;
  130. + // figure out the right way to thread it through instead.
  131. + var domID = hostContainerInfo._idCounter;
  132. + if (!context.__inNoscript) {
  133. + hostContainerInfo._idCounter++;
  134. + }
  135. var openingValue = ' react-text: ' + domID + ' ';
  136. var closingValue = ' /react-text ';
  137. this._domID = domID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement