CodeConvo / react /react.i2c.dev.jsonl
jiebi's picture
Upload CodeConvo dataset
c2b8f63 verified
raw
history blame
246 kB
{"query_id": "q-en-react-8504f1740628b9865d457c3a339d2f782319aaa42fdff1af8180b77ba4b9b7a4", "query": "The last two assertions in this new test don't pass because of the duck-typing check in . Not quite sure what you had in mind here. Not every object whose is a component class is a valid descriptor\u2026 right?\nThis is an intermediate step. Currently the duck typing is flawed regardless. Descriptors will probably get an inheritance chain so that instanceof ReactDescriptor works as a safer check. Only descriptors should pass. We could probably check for props too. It is expected that component classes themselves fail the test. Therefore it should also be renamed. On Feb 24, 2014, at 7:42 AM, Ben Alpert wrote:\nRight -- with the current code, returns true when passed a component class, which is wrong.\nThat's right. We should add that unit test. Out of curiosity, how did you find this? On Feb 24, 2014, at 1:51 PM, Ben Alpert wrote:\nI was adding a warning for passing a component class to renderComponent because of this Stack Overflow question:\nI think this is fixed. Not sure if we have a solid unit test to cover this.", "positive_passages": [{"docid": "doc-en-react-03965b5830162a723889287e9ea7d4a7dd65eea7c43058d52af7de046f28a267", "text": "<ins> /** * Copyright 2013-2014 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the \"License\"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an \"AS IS\" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @jsx React.DOM * @emails react-core */ \"use strict\"; var React; var ReactDescriptor; describe('ReactDescriptor', function() { beforeEach(function() { React = require('React'); ReactDescriptor = require('ReactDescriptor'); }); it('should identify valid descriptors correctly', function() { var Component = React.createClass({ render: function() { return <div />; } }); expect(ReactDescriptor.isValidDescriptor(<div />)).toEqual(true); expect(ReactDescriptor.isValidDescriptor(<Component />)).toEqual(true); expect(ReactDescriptor.isValidDescriptor(null)).toEqual(false); expect(ReactDescriptor.isValidDescriptor(true)).toEqual(false); expect(ReactDescriptor.isValidDescriptor({})).toEqual(false); expect(ReactDescriptor.isValidDescriptor(\"string\")).toEqual(false); expect(ReactDescriptor.isValidDescriptor(React.DOM.div)).toEqual(false); expect(ReactDescriptor.isValidDescriptor(Component)).toEqual(false); }); }); </ins>", "commid": "react_pr_1394"}], "negative_passages": []}
{"query_id": "q-en-react-af28cccd15a54992f5cc048710312a6aeb6577db9cc5753621e969152ef7c8f3", "query": "React adds a scroll listener that tracks and caches the scroll position (I assume for some undocumented internal purpose). Additionally, the scroll listener forces a synchronous layout (see screenshot). This seems wasteful, especially considering that the values tracked are never exposed in the API. What is the scroll listener used for? Can it be removed? !\nViewportMetrics is used to normalize pageX and pageY on mouse events: . Perhaps ironically, it was created to prevent synchronous layouts during mouse event handlers.\nI wish these values (as well as the event) were somehow exposed.\n:+1:\nBTW you can obviously have this if you use a Webpack-like bundler:\nWell, is only used for IE8 and possibly other very old browsers (), so we should be able to just disable it for all other browsers and everyone is happy right? (Could still be optimized slightly for IE8... if anyone cares) Also, That makes no sense at all to me, does not take an argument, yet we get the scroll position and provide it as an argument. Instead, gets the scroll position internally and uses that? So we call twice, but only use the result once (also, this should be broken for events inside iframes, for IE8). Also2, I'm pretty sure any browsers that supports touch, also supports . cc\nI agree that we shouldn't be tracking it in other browsers if we don't need it. I don't know if there's a way to predict whether we'll have .pageX and .pageY before mouse events actually come in.\n:)\nAnother idea being just let resize/scroll set a flag, when a mouse event is created, if the flag is set, update viewport metrics. That way we only update it when needed, but could potentially cause a reflow if there are other events before it (very unlikely though I imagine).\nThis issue causes React based longer lists unusable on mobile.\nIs there any progress on this issue? I\u2019m not sure if this is the root-cause for pages rendered with react scrolling extremely slow with firefox mobile on android (e.g. this react website ).\nIs that your site? If so, you can try commenting out the logic in refreshScrollValues to see if it makes a difference. If it does, I'm happy to prioritize and try to get it in.\nNo, that is not my site, it is an example react & fluxible page (see: ), but we have exactly the same issues with scrolling on firefox mobile. I\u2019ve applied the changes in manually and it doesn\u2019t solves the problem, so this issue might be unrelated to my problem. I will investigate further. Thanks for considering to prioritize this. Much appreciated.", "positive_passages": [{"docid": "doc-en-react-60905e7c7989fb0566ee3fb085b2768fd99e55423986897b205141bb9d5e99a3", "text": "* React Core . General Purpose Event Plugin System */ <ins> var hasEventPageXY; </ins> var alreadyListeningTo = {}; var isMonitoringScrollValue = false; var reactTopListenersCounter = 0;", "commid": "react_pr_6129"}], "negative_passages": []}
{"query_id": "q-en-react-af28cccd15a54992f5cc048710312a6aeb6577db9cc5753621e969152ef7c8f3", "query": "React adds a scroll listener that tracks and caches the scroll position (I assume for some undocumented internal purpose). Additionally, the scroll listener forces a synchronous layout (see screenshot). This seems wasteful, especially considering that the values tracked are never exposed in the API. What is the scroll listener used for? Can it be removed? !\nViewportMetrics is used to normalize pageX and pageY on mouse events: . Perhaps ironically, it was created to prevent synchronous layouts during mouse event handlers.\nI wish these values (as well as the event) were somehow exposed.\n:+1:\nBTW you can obviously have this if you use a Webpack-like bundler:\nWell, is only used for IE8 and possibly other very old browsers (), so we should be able to just disable it for all other browsers and everyone is happy right? (Could still be optimized slightly for IE8... if anyone cares) Also, That makes no sense at all to me, does not take an argument, yet we get the scroll position and provide it as an argument. Instead, gets the scroll position internally and uses that? So we call twice, but only use the result once (also, this should be broken for events inside iframes, for IE8). Also2, I'm pretty sure any browsers that supports touch, also supports . cc\nI agree that we shouldn't be tracking it in other browsers if we don't need it. I don't know if there's a way to predict whether we'll have .pageX and .pageY before mouse events actually come in.\n:)\nAnother idea being just let resize/scroll set a flag, when a mouse event is created, if the flag is set, update viewport metrics. That way we only update it when needed, but could potentially cause a reflow if there are other events before it (very unlikely though I imagine).\nThis issue causes React based longer lists unusable on mobile.\nIs there any progress on this issue? I\u2019m not sure if this is the root-cause for pages rendered with react scrolling extremely slow with firefox mobile on android (e.g. this react website ).\nIs that your site? If so, you can try commenting out the logic in refreshScrollValues to see if it makes a difference. If it does, I'm happy to prioritize and try to get it in.\nNo, that is not my site, it is an example react & fluxible page (see: ), but we have exactly the same issues with scrolling on firefox mobile. I\u2019ve applied the changes in manually and it doesn\u2019t solves the problem, so this issue might be unrelated to my problem. I will investigate further. Thanks for considering to prioritize this. Much appreciated.", "positive_passages": [{"docid": "doc-en-react-53ad83bc411cd1f32a7a7cd5095029155d5ccb095cc51c4f6c09b6ffdfbe7394", "text": "* Listens to window scroll and resize events. We cache scroll values so that * application code can access them without triggering reflows. * <ins> * ViewportMetrics is only used by SyntheticMouse/TouchEvent and only when * pageX/pageY isn't supported (legacy browsers). * </ins> * NOTE: Scroll events do not bubble. * * @see http://www.quirksmode.org/dom/events/scroll.html */ <del> ensureScrollValueMonitoring: function() { if (!isMonitoringScrollValue) { </del> <ins> ensureScrollValueMonitoring: function(){ if (hasEventPageXY === undefined) { hasEventPageXY = document.createEvent && 'pageX' in document.createEvent('MouseEvent'); } if (!hasEventPageXY && !isMonitoringScrollValue) { </ins> var refresh = ViewportMetrics.refreshScrollValues; ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh); isMonitoringScrollValue = true;", "commid": "react_pr_6129"}], "negative_passages": []}
{"query_id": "q-en-react-16680cd16785bd149ce8f71ec27813f47ce0e569c64f71f4fc951f60d8a8becc", "query": "I am working on a project that has strict accessibility requirements. The table I am putting some data in has to implement headers and ids attributes to meet accessibility. See W3 techniques here Unfortunately the \"headers\" attribute is being stripped out because it's not supported by React (it's not on the supported attributes list). Can you please add support for the missing standard attribute called \"headers\"?\n+1\nAs a workaround I believe on a you can grab the DOMNode with a ref and add what you need.", "positive_passages": [{"docid": "doc-en-react-6e3497be782356eca9011a06a8cd1c87499f85f6464b0bdc794757dfabda927b", "text": "form: MUST_USE_ATTRIBUTE, formNoValidate: HAS_BOOLEAN_VALUE, frameBorder: MUST_USE_ATTRIBUTE, <ins> headers: null, </ins> height: MUST_USE_ATTRIBUTE, hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, href: null,", "commid": "react_pr_2553"}], "negative_passages": []}
{"query_id": "q-en-react-dd628f4e74860ad5503f70abb342c44d4f269762880b09391d2158fc46e2c2fb", "query": "If we claim to support IE8, and users are testing their code locally in IE8, they might get thrown into compatibility mode by default. This will cause their webapp to blow up, and they will be confused because IE8 is a supported browser. For background, check out this thread: Users can get out of compatibility mode by adding this tag: Since the current failure is cryptic, and it's easy to detect when IE8 is in compatibility mode (), we should probably add a warning to give a hint to the user that even though they're using IE8, they're actually in compatibility mode (effectively IE7) and should add the meta tag or use one of the other various workarounds.", "positive_passages": [{"docid": "doc-en-react-24c9add1408fb48a3cb885faa2416ac6f2eaf2390804830565af58f69cc78e2e", "text": "var assign = require('Object.assign'); var findDOMNode = require('findDOMNode'); var onlyChild = require('onlyChild'); <ins> var warning = require('warning'); </ins> ReactDefaultInjection.inject();", "commid": "react_pr_3323"}], "negative_passages": []}
{"query_id": "q-en-react-dd628f4e74860ad5503f70abb342c44d4f269762880b09391d2158fc46e2c2fb", "query": "If we claim to support IE8, and users are testing their code locally in IE8, they might get thrown into compatibility mode by default. This will cause their webapp to blow up, and they will be confused because IE8 is a supported browser. For background, check out this thread: Users can get out of compatibility mode by adding this tag: Since the current failure is cryptic, and it's easy to detect when IE8 is in compatibility mode (), we should probably add a warning to give a hint to the user that even though they're using IE8, they're actually in compatibility mode (effectively IE7) and should add the meta tag or use one of the other various workarounds.", "positive_passages": [{"docid": "doc-en-react-98cd49c00676a483b8bb9831879fa49838f40b437120186f4fda5e0af888bf58", "text": "} } <ins> // If we're in IE8, check to see if we are in combatibility mode and provide // information on preventing compatibility mode var ieCompatibilityMode = document.documentMode && document.documentMode < 8; warning( !ieCompatibilityMode, 'Internet Explorer is running in compatibility mode, please add the following ' + 'tag to your HTML to prevent this from happening: ' + '<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />' ); </ins> var expectedFeatures = [ // shims Array.isArray,", "commid": "react_pr_3323"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-b8552e574aa63e00ff7351642a17caf16de211243d02c96e8eb0e205f2b901df", "text": "var MARKDOWN_COMPONENT = ` <del> var converter = new Showdown.converter(); </del> var MarkdownEditor = React.createClass({ getInitialState: function() { return {value: 'Type some *markdown* here!'};", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-4ea2cc92e2a4b7cb71fe9907df30e1a5477772eb55fe5a3809dd716aa0aa3557", "text": "<div className=\"content\" dangerouslySetInnerHTML={{ <del> __html: converter.makeHtml(this.state.value) </del> <ins> __html: marked(this.state.value, {sanitize: true}) </ins> }} /> </div>", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-2be836c71d84ab1ae1a8bac90b0a5eeae0f38355b7cedb761ac3c10c9092c0d9", "text": "<script type=\"text/javascript\" src=\"/react/js/react.js\"></script> <script type=\"text/javascript\" src=\"/react/js/JSXTransformer.js\"></script> <script type=\"text/javascript\" src=\"/react/js/live_editor.js\"></script> <del> <script type=\"text/javascript\" src=\"/react/js/showdown.js\"></script> </del> </head> <body>", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-20ce2b27ca5a000860017820efe9643aa6f9e00c779b16e6ed8aeeb6eb93ec59", "text": "Markdown is a simple way to format your text inline. For example, surrounding text with asterisks will make it emphasized. <del> First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground): </del> <ins> First, add the third-party library **marked** to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground): </ins> ```html{7} <!-- index.html -->", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-b1519f314bfffaf415cf930144d222c8a1f05b3be25746cc6b8ac66f08522fa8", "text": "<script src=\"https://fb.me/react-{{site.react_version}}.js\"></script> <script src=\"https://fb.me/JSXTransformer-{{site.react_version}}.js\"></script> <script src=\"https://code.jquery.com/jquery-1.10.0.min.js\"></script> <del> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js\"></script> </del> <ins> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js\"></script> </ins> </head> ``` Next, let's convert the comment text to Markdown and output it: <del> ```javascript{2,10} </del> <ins> ```javascript{9} </ins> // tutorial6.js <del> var converter = new Showdown.converter(); </del> var Comment = React.createClass({ render: function() { return (", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-f877b520452d96b851af3f845bd6425f3d0d405a62ed065724b86124e4200801", "text": "<h2 className=\"commentAuthor\"> {this.props.author} </h2> <del> {converter.makeHtml(this.props.children.toString())} </del> <ins> {marked(this.props.children.toString())} </ins> </div> ); } }); ``` <del> All we're doing here is calling the Showdown library. We need to convert `this.props.children` from React's wrapped text to a raw string that Showdown will understand so we explicitly call `toString()`. </del> <ins> All we're doing here is calling the marked library. We need to convert `this.props.children` from React's wrapped text to a raw string that marked will understand so we explicitly call `toString()`. </ins> But there's a problem! Our rendered comments look like this in the browser: \"`<p>`This is `<em>`another`</em>` comment`</p>`\". We want those tags to actually render as HTML. That's React protecting you from an XSS attack. There's a way to get around it but the framework warns you not to use it: <del> ```javascript{5,11} </del> <ins> ```javascript{4,10} </ins> // tutorial7.js <del> var converter = new Showdown.converter(); </del> var Comment = React.createClass({ render: function() { <del> var rawMarkup = converter.makeHtml(this.props.children.toString()); </del> <ins> var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); </ins> return ( <div className=\"comment\"> <h2 className=\"commentAuthor\">", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-564d32c40fb2c0c6d1a71ba75d5b644cc5c140e76114a8e2db89df198345e08a", "text": "}); ``` <del> This is a special API that intentionally makes it difficult to insert raw HTML, but for Showdown we'll take advantage of this backdoor. </del> <ins> This is a special API that intentionally makes it difficult to insert raw HTML, but for marked we'll take advantage of this backdoor. </ins> <del> **Remember:** by using this feature you're relying on Showdown to be secure. </del> <ins> **Remember:** by using this feature you're relying on marked to be secure. In this case, we pass `sanitize: true` which tells marked to escape any HTML markup in the source instead of passing it through unchanged. </ins> ### Hook up the data model", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-9df92b0e5d61e86c236bdc38559c41b06e0c72a3c7e46abcf312215f2ca96a57", "text": "<h3>A Component Using External Plugins</h3> <p> React is flexible and provides hooks that allow you to interface with <del> other libraries and frameworks. This example uses Showdown, an external </del> <ins> other libraries and frameworks. This example uses **marked**, an external </ins> Markdown library, to convert the textarea's value in real-time. </p> <div id=\"markdownExample\"></div> </div> </div> <del> <script type=\"text/javascript\" src=\"js/examples/hello.js\"></script> <script type=\"text/javascript\" src=\"js/examples/timer.js\"></script> <script type=\"text/javascript\" src=\"js/examples/todo.js\"></script> <script type=\"text/javascript\" src=\"js/examples/markdown.js\"></script> </del> <ins> <script type=\"text/javascript\" src=\"/react/js/marked.min.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/hello.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/timer.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/todo.js\"></script> <script type=\"text/javascript\" src=\"/react/js/examples/markdown.js\"></script> </ins> </section> <hr class=\"home-divider\" /> <section class=\"home-bottom-section\">", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-d3ae4a1acc61fdbcb7663668bbb60e23452eda1e31b97abf9aacc538395b6a97", "text": "<ins> /** * marked - a markdown parser * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) * https://github.com/chjj/marked */ (function(){var block={newline:/^n+/,code:/^( {4}[^n]+n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:n+|$)/,heading:/^ *(#{1,6}) *([^n]+?) *#* *(?:n+|$)/,nptable:noop,lheading:/^([^n]+)n *(=|-){2,} *(?:n+|$)/,blockquote:/^( *>[^n]+(n(?!def)[^n]+)*n*)+/,list:/^( *)(bull) [sS]+?(?:hr|def|n{2,}(?! )(?!1bull )n*|s*$)/,html:/^ *(?:comment|closed|closing) *(?:n{2,}|s*$)/,def:/^ *[([^]]+)]: *<?([^s>]+)>?(?: +[\"(]([^n]+)[\")])? *(?:n+|$)/,table:noop,paragraph:/^((?:[^n]+n?(?!hr|heading|lheading|blockquote|tag|def))+)n*/,text:/^[^n]+/};block.bullet=/(?:[*+-]|d+.)/;block.item=/^( *)(bull) [^n]*(?:n(?!1bull )[^n]*)*/;block.item=replace(block.item,\"gm\")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)(\"hr\",\"n+(?=1?(?:[-*_] *){3,}(?:n+|$))\")(\"def\",\"n+(?=\"+block.def.source+\")\")();block.blockquote=replace(block.blockquote)(\"def\",block.def)();block._tag=\"(?!(?:\"+\"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code\"+\"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo\"+\"|span|br|wbr|ins|del|img)b)w+(?!:/|[^ws@]*@)b\";block.html=replace(block.html)(\"comment\",/<!--[sS]*?-->/)(\"closed\",/<(tag)[sS]+?</1>/)(\"closing\",/<tag(?:\"[^\"]*\"|'[^']*'|[^'\">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)(\"hr\",block.hr)(\"heading\",block.heading)(\"lheading\",block.lheading)(\"blockquote\",block.blockquote)(\"tag\",\"<\"+block._tag)(\"def\",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(S+)? *n([sS]+?)s*1 *(?:n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)(\"(?!\",\"(?!\"+block.gfm.fences.source.replace(\"1\",\"2\")+\"|\"+block.list.source.replace(\"1\",\"3\")+\"|\")();block.tables=merge({},block.gfm,{nptable:/^ *(S.*|.*)n *([-:]+ *|[-| :]*)n((?:.*|.*(?:n|$))*)n*/,table:/^ *|(.+)n *|( *[-:]+[-| :]*)n((?: *|.*(?:n|$))*)n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/rn|r/g,\"n\").replace(/t/g,\" \").replace(/u00a0/g,\" \").replace(/u2424/g,\"n\");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,\"\"),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:\"space\"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,\"\");this.tokens.push({type:\"code\",text:!this.options.pedantic?cap.replace(/n+$/,\"\"):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"code\",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"heading\",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:\"table\",header:cap[1].replace(/^ *| *| *$/g,\"\").split(/ *| */),align:cap[2].replace(/^ *|| *$/g,\"\").split(/ *| */),cells:cap[3].replace(/n$/,\"\").split(\"n\")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]=\"right\"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]=\"center\"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]=\"left\"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].split(/ *| */)}this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"heading\",depth:cap[2]===\"=\"?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"hr\"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"blockquote_start\"});cap=cap[0].replace(/^ *> ?/gm,\"\");this.token(cap,top,true);this.tokens.push({type:\"blockquote_end\"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:\"list_start\",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|d+.) +/,\"\");if(~item.indexOf(\"n \")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp(\"^ {1,\"+space+\"}\",\"gm\"),\"\"):item.replace(/^ {1,4}/gm,\"\")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+1).join(\"n\")+src;i=l-1}}loose=next||/nn(?!s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)===\"n\";if(!loose)loose=next}this.tokens.push({type:loose?\"loose_item_start\":\"list_item_start\"});this.token(item,false,bq);this.tokens.push({type:\"list_item_end\"})}this.tokens.push({type:\"list_end\"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?\"paragraph\":\"html\",pre:cap[1]===\"pre\"||cap[1]===\"script\"||cap[1]===\"style\",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:\"table\",header:cap[1].replace(/^ *| *| *$/g,\"\").split(/ *| */),align:cap[2].replace(/^ *|| *$/g,\"\").split(/ *| */),cells:cap[3].replace(/(?: *| *)?n$/,\"\").split(\"n\")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]=\"right\"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]=\"center\"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]=\"left\"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].replace(/^ *| *| *| *$/g,\"\").split(/ *| */)}this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:\"paragraph\",text:cap[1].charAt(cap[1].length-1)===\"n\"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:\"text\",text:cap[0]});continue}if(src){throw new Error(\"Infinite loop on byte: \"+src.charCodeAt(0))}}return this.tokens};var inline={escape:/^([`*{}[]()#+-.!_>])/,autolink:/^<([^ >]+(@|:/)[^ >]+)>/,url:noop,tag:/^<!--[sS]*?-->|^</?w+(?:\"[^\"]*\"|'[^']*'|[^'\">])*?>/,link:/^!?[(inside)](href)/,reflink:/^!?[(inside)]s*[([^]]*)]/,nolink:/^!?[((?:[[^]]*]|[^[]])*)]/,strong:/^__([sS]+?)__(?!_)|^**([sS]+?)**(?!*)/,em:/^b_((?:__|[sS])+?)_b|^*((?:**|[sS])+?)*(?!*)/,code:/^(`+)s*([sS]*?[^`])s*1(?!`)/,br:/^ {2,}n(?!s*$)/,del:noop,text:/^[sS]+?(?=[<![_*`]| {2,}n|$)/};inline._inside=/(?:[[^]]*]|[^[]]|](?=[^[]*]))*/;inline._href=/s*<?([sS]*?)>?(?:s+['\"]([sS]*?)['\"])?s*/;inline.link=replace(inline.link)(\"inside\",inline._inside)(\"href\",inline._href)();inline.reflink=replace(inline.reflink)(\"inside\",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=S)([sS]*?S)__(?!_)|^**(?=S)([sS]*?S)**(?!*)/,em:/^_(?=S)([sS]*?S)_(?!_)|^*(?=S)([sS]*?S)*(?!*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)(\"])\",\"~|])\")(),url:/^(https?://[^s<]+[^<.,:;\"')]s])/,del:/^~~(?=S)([sS]*?S)~~/,text:replace(inline.text)(\"]|\",\"~]|\")(\"|\",\"|https?://|\")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)(\"{2,}\",\"*\")(),text:replace(inline.gfm.text)(\"{2,}\",\"*\")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error(\"Tokens array requires a `links` property.\")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out=\"\",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]===\"@\"){text=cap[1].charAt(6)===\":\"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle(\"mailto:\")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^<a /i.test(cap[0])){this.inLink=true}else if(this.inLink&&/^</a>/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/s+/g,\" \");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error(\"Infinite loop on byte: \"+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!==\"!\"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,\"\u2014\").replace(/(^|[-u2014/([{\"s])'/g,\"$1\u2018\").replace(/'/g,\"\u2019\").replace(/(^|[-u2014/([{u2018s])\"/g,\"$1\u201c\").replace(/\"/g,\"\u201d\").replace(/.{3}/g,\"\u2026\")};InlineLexer.prototype.mangle=function(text){var out=\"\",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>.5){ch=\"x\"+ch.toString(16)}out+=\"&#\"+ch+\";\"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return\"<pre><code>\"+(escaped?code:escape(code,true))+\"n</code></pre>\"}return'<pre><code class=\"'+this.options.langPrefix+escape(lang,true)+'\">'+(escaped?code:escape(code,true))+\"n</code></pre>n\"};Renderer.prototype.blockquote=function(quote){return\"<blockquote>n\"+quote+\"</blockquote>n\"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return\"<h\"+level+' id=\"'+this.options.headerPrefix+raw.toLowerCase().replace(/[^w]+/g,\"-\")+'\">'+text+\"</h\"+level+\">n\"};Renderer.prototype.hr=function(){return this.options.xhtml?\"<hr/>n\":\"<hr>n\"};Renderer.prototype.list=function(body,ordered){var type=ordered?\"ol\":\"ul\";return\"<\"+type+\">n\"+body+\"</\"+type+\">n\"};Renderer.prototype.listitem=function(text){return\"<li>\"+text+\"</li>n\"};Renderer.prototype.paragraph=function(text){return\"<p>\"+text+\"</p>n\"};Renderer.prototype.table=function(header,body){return\"<table>n\"+\"<thead>n\"+header+\"</thead>n\"+\"<tbody>n\"+body+\"</tbody>n\"+\"</table>n\"};Renderer.prototype.tablerow=function(content){return\"<tr>n\"+content+\"</tr>n\"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?\"th\":\"td\";var tag=flags.align?\"<\"+type+' style=\"text-align:'+flags.align+'\">':\"<\"+type+\">\";return tag+content+\"</\"+type+\">n\"};Renderer.prototype.strong=function(text){return\"<strong>\"+text+\"</strong>\"};Renderer.prototype.em=function(text){return\"<em>\"+text+\"</em>\"};Renderer.prototype.codespan=function(text){return\"<code>\"+text+\"</code>\"};Renderer.prototype.br=function(){return this.options.xhtml?\"<br/>\":\"<br>\"};Renderer.prototype.del=function(text){return\"<del>\"+text+\"</del>\"};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^w:]/g,\"\").toLowerCase()}catch(e){return\"\"}if(prot.indexOf(\"javascript:\")===0){return\"\"}}var out='<a href=\"'+href+'\"';if(title){out+=' title=\"'+title+'\"'}out+=\">\"+text+\"</a>\";return out};Renderer.prototype.image=function(href,title,text){var out='<img src=\"'+href+'\" alt=\"'+text+'\"';if(title){out+=' title=\"'+title+'\"'}out+=this.options.xhtml?\"/>\":\">\";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out=\"\";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type===\"text\"){body+=\"n\"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case\"space\":{return\"\"}case\"hr\":{return this.renderer.hr()}case\"heading\":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case\"code\":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case\"table\":{var header=\"\",body=\"\",i,row,cell,flags,j;cell=\"\";for(i=0;i<this.token.header.length;i++){flags={header:true,align:this.token.align[i]};cell+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:true,align:this.token.align[i]})}header+=this.renderer.tablerow(cell);for(i=0;i<this.token.cells.length;i++){row=this.token.cells[i];cell=\"\";for(j=0;j<row.length;j++){cell+=this.renderer.tablecell(this.inline.output(row[j]),{header:false,align:this.token.align[j]})}body+=this.renderer.tablerow(cell)}return this.renderer.table(header,body)}case\"blockquote_start\":{var body=\"\";while(this.next().type!==\"blockquote_end\"){body+=this.tok()}return this.renderer.blockquote(body)}case\"list_start\":{var body=\"\",ordered=this.token.ordered;while(this.next().type!==\"list_end\"){body+=this.tok()}return this.renderer.list(body,ordered)}case\"list_item_start\":{var body=\"\";while(this.next().type!==\"list_item_end\"){body+=this.token.type===\"text\"?this.parseText():this.tok()}return this.renderer.listitem(body)}case\"loose_item_start\":{var body=\"\";while(this.next().type!==\"list_item_end\"){body+=this.tok()}return this.renderer.listitem(body)}case\"html\":{var html=!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;return this.renderer.html(html)}case\"paragraph\":{return this.renderer.paragraph(this.inline.output(this.token.text))}case\"text\":{return this.renderer.paragraph(this.parseText())}}};function escape(html,encode){return html.replace(!encode?/&(?!#?w+;)/g:/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\"/g,\"&quot;\").replace(/'/g,\"&#39;\")}function unescape(html){return html.replace(/&([#w]+);/g,function(_,n){n=n.toLowerCase();if(n===\"colon\")return\":\";if(n.charAt(0)===\"#\"){return n.charAt(1)===\"x\"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return\"\"})}function replace(regex,opt){regex=regex.source;opt=opt||\"\";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^[])^/g,\"$1\");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target){if(Object.prototype.hasOwnProperty.call(target,key)){obj[key]=target[key]}}}return obj}function marked(src,opt,callback){if(callback||typeof opt===\"function\"){if(!callback){callback=opt;opt=null}opt=merge({},marked.defaults,opt||{});var highlight=opt.highlight,tokens,pending,i=0;try{tokens=Lexer.lex(src,opt)}catch(e){return callback(e)}pending=tokens.length;var done=function(){var out,err;try{out=Parser.parse(tokens,opt)}catch(e){err=e}opt.highlight=highlight;return err?callback(err):callback(null,out)};if(!highlight||highlight.length<3){return done()}delete opt.highlight;if(!pending)return done();for(;i<tokens.length;i++){(function(token){if(token.type!==\"code\"){return--pending||done()}return highlight(token.text,token.lang,function(err,code){if(code==null||code===token.text){return--pending||done()}token.text=code;token.escaped=true;--pending||done()})})(tokens[i])}return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+=\"nPlease report this to https://github.com/chjj/marked.\";if((opt||marked.defaults).silent){return\"<p>An error occured:</p><pre>\"+escape(e.message+\"\",true)+\"</pre>\"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:\"lang-\",smartypants:false,headerPrefix:\"\",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof exports===\"object\"){module.exports=marked}else if(typeof define===\"function\"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!==\"undefined\"?window:global)}()); </ins> No newline at end of file", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-bda68aba5b773f0e231d8ae9f598c5dea11ff75961a86d42353566558f7ff8f7", "query": "Since copy+pasting our code makes it too easy for people to XSS themselves, lets just add a comment in there about it.\nPR at - let me know if that's what you had in mind!\nMy intuition is that it makes more sense to fix the example (call a sanitization library) or to change the example completely (demonstrate something else that is safer). It looks really bad to have a security warning on the homepage of the react site. Makes it seem like our framework encourages unsafe operations, rather than a safe-by-default way of doing things.\nShould switch the demo to use a different library like markdown-js that escapes everything and doesn't support HTML:\nmarkdown-js looks good. First attempt: ,output Code licensed if someone wants to turn this into a coherent example; I've signed the CLA.\nThat's a good suggestion too :) - what are your thoughts? I'm happy to change the example to use like people have suggested above. nice usage example :+1:\nUh yea, that sounds fine to me. This behavior is definitely non-standard markdown but it's an example so not a big deal. We should probably do the same for the tutorial while we're here. And it's on cdnjs so that's all pretty easy:\nJust going to use marked instead, which I'm already familiar with and has an option to sanitize input.", "positive_passages": [{"docid": "doc-en-react-320fb007e8626bf23a4b5d9396e86f181bc8b6c98f43abd30ac69de3fc173817", "text": "<del> // // showdown.js -- A javascript port of Markdown. // // Copyright (c) 2007 John Fraser. // // Original Markdown Copyright (c) 2004-2005 John Gruber // <http://daringfireball.net/projects/markdown/> // // Redistributable under a BSD-style open source license. // See license.txt for more information. // // The full source distribution is at: // //\t\t\t\tA A L //\t\t\t\tT C A //\t\t\t\tT K B // // <http://www.attacklab.net/> // // // Wherever possible, Showdown is a straight, line-by-line port // of the Perl version of Markdown. // // This is not a normal parser design; it's basically just a // series of string substitutions. It's hard to read and // maintain this way, but keeping Showdown close to the original // design makes it easier to port new features. // // More importantly, Showdown behaves like markdown.pl in most // edge cases. So web applications can do client-side preview // in Javascript, and then build identical HTML on the server. // // This port needs the new RegExp functionality of ECMA 262, // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers // should do fine. Even with the new regular expression features, // We do a lot of work to emulate Perl's regex functionality. // The tricky changes in this file mostly have the \"attacklab:\" // label. Major or self-explanatory changes don't. // // Smart diff tools like Araxis Merge will be able to match up // this file with markdown.pl in a useful way. A little tweaking // helps: in a copy of markdown.pl, replace \"#\" with \"//\" and // replace \"$text\" with \"text\". Be sure to ignore whitespace // and line endings. // // // Showdown usage: // // var text = \"Markdown *rocks*.\"; // // var converter = new Showdown.converter(); // var html = converter.makeHtml(text); // // alert(html); // // Note: move the sample code to the bottom of this // file before uncommenting it. // // // Showdown namespace // var Showdown = {}; // // converter // // Wraps all \"globals\" so that the only thing // exposed is makeHtml(). // Showdown.converter = function() { // // Globals: // // Global hashes, used by various utility routines var g_urls; var g_titles; var g_html_blocks; // Used to track when we're inside an ordered or unordered list // (see _ProcessListItems() for details): var g_list_level = 0; this.makeHtml = function(text) { // // Main function. The order in which other subs are called here is // essential. Link and image substitutions need to happen before // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a> // and <img> tags get encoded. // // Clear the global hashes. If we don't clear these, you get conflicts // from other articles when generating a page which contains more than // one article (e.g. an index page that shows the N most recent // articles): g_urls = new Array(); g_titles = new Array(); g_html_blocks = new Array(); // attacklab: Replace ~ with ~T // This lets us use tilde as an escape char to avoid md5 hashes // The choice of character is arbitray; anything that isn't // magic in Markdown will work. text = text.replace(/~/g,\"~T\"); // attacklab: Replace $ with ~D // RegExp interprets $ as a special character // when it's in a replacement string text = text.replace(/$/g,\"~D\"); // Standardize line endings text = text.replace(/rn/g,\"n\"); // DOS to Unix text = text.replace(/r/g,\"n\"); // Mac to Unix // Make sure text begins and ends with a couple of newlines: text = \"nn\" + text + \"nn\"; // Convert all tabs to spaces. text = _Detab(text); // Strip any lines consisting only of spaces and tabs. // This makes subsequent regexen easier to write, because we can // match consecutive blank lines with /n+/ instead of something // contorted like /[ t]*n+/ . text = text.replace(/^[ t]+$/mg,\"\"); // Turn block-level HTML blocks into hash entries text = _HashHTMLBlocks(text); // Strip link definitions, store in hashes. text = _StripLinkDefinitions(text); text = _RunBlockGamut(text); text = _UnescapeSpecialChars(text); // attacklab: Restore dollar signs text = text.replace(/~D/g,\"$$\"); // attacklab: Restore tildes text = text.replace(/~T/g,\"~\"); return text; } var _StripLinkDefinitions = function(text) { // // Strips link definitions from text, stores the URLs and titles in // hash references. // // Link defs are in the form: ^[id]: url \"optional title\" /* var text = text.replace(/ ^[ ]{0,3}[(.+)]: // id = $1 attacklab: g_tab_width - 1 [ t]* n?\t\t\t\t// maybe *one* newline [ t]* <?(S+?)>?\t\t\t// url = $2 [ t]* n?\t\t\t\t// maybe one newline [ t]* (?: (n*)\t\t\t\t// any lines skipped = $3 attacklab: lookbehind removed [\"(] (.+?)\t\t\t\t// title = $4 [\")] [ t]* )?\t\t\t\t\t// title is optional (?:n+|$) /gm, function(){...}); */ var text = text.replace(/^[ ]{0,3}[(.+)]:[ t]*n?[ t]*<?(S+?)>?[ t]*n?[ t]*(?:(n*)[\"(](.+?)[\")][ t]*)?(?:n+|Z)/gm, function (wholeMatch,m1,m2,m3,m4) { m1 = m1.toLowerCase(); g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive if (m3) { // Oops, found blank lines, so it's not a title. // Put back the parenthetical statement we stole. return m3+m4; } else if (m4) { g_titles[m1] = m4.replace(/\"/g,\"&quot;\"); } // Completely remove the definition from the text return \"\"; } ); return text; } var _HashHTMLBlocks = function(text) { // attacklab: Double up blank lines to reduce lookaround text = text.replace(/n/g,\"nn\"); // Hashify HTML blocks: // We only want to do this for block-level HTML tags, such as headers, // lists, and tables. That's because we still want to wrap <p>s around // \"paragraphs\" that are wrapped in non-block-level tags, such as anchors, // phrase emphasis, and spans. The list of tags we're looking for is // hard-coded: var block_tags_a = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del\" var block_tags_b = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math\" // First, look for nested blocks, e.g.: // <div> // <div> // tags for inner block must be indented. // </div> // </div> // // The outermost tags must start at the left margin for this to match, and // the inner nested divs must be indented. // We need to do this before the next, more liberal match, because the next // match will start at the first `<div>` and stop at the first `</div>`. // attacklab: This regex can be expensive when it fails. /* var text = text.replace(/ (\t\t\t\t\t\t// save in $1 ^\t\t\t\t\t// start of line (with /m) <($block_tags_a)\t// start tag = $2 b\t\t\t\t\t// word break // attacklab: hack around khtml/pcre bug... [^r]*?n\t\t\t// any number of lines, minimally matching </2>\t\t\t\t// the matching end tag [ t]*\t\t\t\t// trailing spaces/tabs (?=n+)\t\t\t\t// followed by a newline )\t\t\t\t\t\t// attacklab: there are sentinel newlines at end of document /gm,function(){...}}; */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)b[^r]*?n</2>[ t]*(?=n+))/gm,hashElement); // // Now match more liberally, simply from `n<tag>` to `</tag>n` // /* var text = text.replace(/ (\t\t\t\t\t\t// save in $1 ^\t\t\t\t\t// start of line (with /m) <($block_tags_b)\t// start tag = $2 b\t\t\t\t\t// word break // attacklab: hack around khtml/pcre bug... [^r]*?\t\t\t\t// any number of lines, minimally matching .*</2>\t\t\t\t// the matching end tag [ t]*\t\t\t\t// trailing spaces/tabs (?=n+)\t\t\t\t// followed by a newline )\t\t\t\t\t\t// attacklab: there are sentinel newlines at end of document /gm,function(){...}}; */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)b[^r]*?.*</2>[ t]*(?=n+)n)/gm,hashElement); // Special case just for <hr />. It was easier to make a special case than // to make the other regex more complicated. /* text = text.replace(/ (\t\t\t\t\t\t// save in $1 nn\t\t\t\t// Starting after a blank line [ ]{0,3} (<(hr)\t\t\t\t// start tag = $2 b\t\t\t\t\t// word break ([^<>])*?\t\t\t// /?>)\t\t\t\t// the matching end tag [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(n[ ]{0,3}(<(hr)b([^<>])*?/?>)[ t]*(?=n{2,}))/g,hashElement); // Special case for standalone HTML comments: /* text = text.replace(/ (\t\t\t\t\t\t// save in $1 nn\t\t\t\t// Starting after a blank line [ ]{0,3}\t\t\t// attacklab: g_tab_width - 1 <! (--[^r]*?--s*)+ > [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(nn[ ]{0,3}<!(--[^r]*?--s*)+>[ t]*(?=n{2,}))/g,hashElement); // PHP and ASP-style processor instructions (<?...?> and <%...%>) /* text = text.replace(/ (?: nn\t\t\t\t// Starting after a blank line ) (\t\t\t\t\t\t// save in $1 [ ]{0,3}\t\t\t// attacklab: g_tab_width - 1 (?: <([?%])\t\t\t// $2 [^r]*? 2> ) [ t]* (?=n{2,})\t\t\t// followed by a blank line ) /g,hashElement); */ text = text.replace(/(?:nn)([ ]{0,3}(?:<([?%])[^r]*?2>)[ t]*(?=n{2,}))/g,hashElement); // attacklab: Undo double lines (see comment at top of this function) text = text.replace(/nn/g,\"n\"); return text; } var hashElement = function(wholeMatch,m1) { var blockText = m1; // Undo double lines blockText = blockText.replace(/nn/g,\"n\"); blockText = blockText.replace(/^n/,\"\"); // strip trailing blank lines blockText = blockText.replace(/n+$/g,\"\"); // Replace the element text with a marker (\"~KxK\" where x is its key) blockText = \"nn~K\" + (g_html_blocks.push(blockText)-1) + \"Knn\"; return blockText; }; var _RunBlockGamut = function(text) { // // These are all the transformations that form block-level // tags like paragraphs, headers, and list items. // text = _DoHeaders(text); // Do Horizontal Rules: var key = hashBlock(\"<hr />\"); text = text.replace(/^[ ]{0,2}([ ]?*[ ]?){3,}[ t]*$/gm,key); text = text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ t]*$/gm,key); text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ t]*$/gm,key); text = _DoLists(text); text = _DoCodeBlocks(text); text = _DoBlockQuotes(text); // We already ran _HashHTMLBlocks() before, in Markdown(), but that // was to escape raw HTML in the original Markdown source. This time, // we're escaping the markup we've just created, so that we don't wrap // <p> tags around block-level tags. text = _HashHTMLBlocks(text); text = _FormParagraphs(text); return text; } var _RunSpanGamut = function(text) { // // These are all the transformations that occur *within* block-level // tags like paragraphs, headers, and list items. // text = _DoCodeSpans(text); text = _EscapeSpecialCharsWithinTagAttributes(text); text = _EncodeBackslashEscapes(text); // Process anchor and image tags. Images must come first, // because ![foo][f] looks like an anchor. text = _DoImages(text); text = _DoAnchors(text); // Make links out of things like `<http://example.com/>` // Must come after _DoAnchors(), because you can use < and > // delimiters in inline links like [this](<url>). text = _DoAutoLinks(text); text = _EncodeAmpsAndAngles(text); text = _DoItalicsAndBold(text); // Do hard breaks: text = text.replace(/ +n/g,\" <br />n\"); return text; } var _EscapeSpecialCharsWithinTagAttributes = function(text) { // // Within tags -- meaning between < and > -- encode [ ` * _] so they // don't conflict with their use in Markdown for code, italics and strong. // // Build a regex to find HTML tags and comments. See Friedl's // \"Mastering Regular Expressions\", 2nd Ed., pp. 200-201. var regex = /(<[a-z/!$](\"[^\"]*\"|'[^']*'|[^'\">])*>|<!(--.*?--s*)+>)/gi; text = text.replace(regex, function(wholeMatch) { var tag = wholeMatch.replace(/(.)</?code>(?=.)/g,\"$1`\"); tag = escapeCharacters(tag,\"`*_\"); return tag; }); return text; } var _DoAnchors = function(text) { // // Turn Markdown link shortcuts into XHTML <a> tags. // // // First, handle reference-style links: [link text] [id] // /* text = text.replace(/ (\t\t\t\t\t\t\t// wrap whole match in $1 [ ( (?: [[^]]*]\t\t// allow brackets nested one level | [^[]\t\t\t// or anything else )* ) ] [ ]?\t\t\t\t\t// one optional space (?:n[ ]*)?\t\t\t\t// one optional newline followed by spaces [ (.*?)\t\t\t\t\t// id = $3 ] )()()()()\t\t\t\t\t// pad remaining backreferences /g,_DoAnchors_callback); */ text = text.replace(/([((?:[[^]]*]|[^[]])*)][ ]?(?:n[ ]*)?[(.*?)])()()()()/g,writeAnchorTag); // // Next, inline-style links: [link text](url \"optional title\") // /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 [ ( (?: [[^]]*]\t// allow brackets nested one level | [^[]]\t\t\t// or anything else ) ) ] (\t\t\t\t\t\t// literal paren [ t]* ()\t\t\t\t\t\t// no id, so leave $3 empty <?(.*?)>?\t\t\t\t// href = $4 [ t]* (\t\t\t\t\t\t// $5 (['\"])\t\t\t\t// quote char = $6 (.*?)\t\t\t\t// Title = $7 6\t\t\t\t\t// matching quote [ t]*\t\t\t\t// ignore any spaces/tabs between closing quote and ) )?\t\t\t\t\t\t// title is optional ) ) /g,writeAnchorTag); */ text = text.replace(/([((?:[[^]]*]|[^[]])*)]([ t]*()<?(.*?)>?[ t]*((['\"])(.*?)6[ t]*)?))/g,writeAnchorTag); // // Last, handle reference-style shortcuts: [link text] // These must come last in case you've also got [link test][1] // or [link test](/foo) // /* text = text.replace(/ (\t\t \t\t\t\t\t// wrap whole match in $1 [ ([^[]]+)\t\t\t\t// link text = $2; can't contain '[' or ']' ] )()()()()()\t\t\t\t\t// pad rest of backreferences /g, writeAnchorTag); */ text = text.replace(/([([^[]]+)])()()()()()/g, writeAnchorTag); return text; } var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { if (m7 == undefined) m7 = \"\"; var whole_match = m1; var link_text = m2; var link_id\t = m3.toLowerCase(); var url\t\t= m4; var title\t= m7; if (url == \"\") { if (link_id == \"\") { // lower-case and turn embedded newlines into spaces link_id = link_text.toLowerCase().replace(/ ?n/g,\" \"); } url = \"#\"+link_id; if (g_urls[link_id] != undefined) { url = g_urls[link_id]; if (g_titles[link_id] != undefined) { title = g_titles[link_id]; } } else { if (whole_match.search(/(s*)$/m)>-1) { // Special case for explicit empty url url = \"\"; } else { return whole_match; } } } url = escapeCharacters(url,\"*_\"); var result = \"<a href=\"\" + url + \"\"\"; if (title != \"\") { title = title.replace(/\"/g,\"&quot;\"); title = escapeCharacters(title,\"*_\"); result += \" title=\"\" + title + \"\"\"; } result += \">\" + link_text + \"</a>\"; return result; } var _DoImages = function(text) { // // Turn Markdown image shortcuts into <img> tags. // // // First, handle reference-style labeled images: ![alt text][id] // /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 ![ (.*?)\t\t\t\t// alt text = $2 ] [ ]?\t\t\t\t// one optional space (?:n[ ]*)?\t\t\t// one optional newline followed by spaces [ (.*?)\t\t\t\t// id = $3 ] )()()()()\t\t\t\t// pad rest of backreferences /g,writeImageTag); */ text = text.replace(/(![(.*?)][ ]?(?:n[ ]*)?[(.*?)])()()()()/g,writeImageTag); // // Next, handle inline images: ![alt text](url \"optional title\") // Don't forget: encode * and _ /* text = text.replace(/ (\t\t\t\t\t\t// wrap whole match in $1 ![ (.*?)\t\t\t\t// alt text = $2 ] s?\t\t\t\t\t// One optional whitespace character (\t\t\t\t\t// literal paren [ t]* ()\t\t\t\t\t// no id, so leave $3 empty <?(S+?)>?\t\t\t// src url = $4 [ t]* (\t\t\t\t\t// $5 (['\"])\t\t\t// quote char = $6 (.*?)\t\t\t// title = $7 6\t\t\t\t// matching quote [ t]* )?\t\t\t\t\t// title is optional ) ) /g,writeImageTag); */ text = text.replace(/(![(.*?)]s?([ t]*()<?(S+?)>?[ t]*((['\"])(.*?)6[ t]*)?))/g,writeImageTag); return text; } var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { var whole_match = m1; var alt_text = m2; var link_id\t = m3.toLowerCase(); var url\t\t= m4; var title\t= m7; if (!title) title = \"\"; if (url == \"\") { if (link_id == \"\") { // lower-case and turn embedded newlines into spaces link_id = alt_text.toLowerCase().replace(/ ?n/g,\" \"); } url = \"#\"+link_id; if (g_urls[link_id] != undefined) { url = g_urls[link_id]; if (g_titles[link_id] != undefined) { title = g_titles[link_id]; } } else { return whole_match; } } alt_text = alt_text.replace(/\"/g,\"&quot;\"); url = escapeCharacters(url,\"*_\"); var result = \"<img src=\"\" + url + \"\" alt=\"\" + alt_text + \"\"\"; // attacklab: Markdown.pl adds empty title attributes to images. // Replicate this bug. //if (title != \"\") { title = title.replace(/\"/g,\"&quot;\"); title = escapeCharacters(title,\"*_\"); result += \" title=\"\" + title + \"\"\"; //} result += \" />\"; return result; } var _DoHeaders = function(text) { // Setext-style headers: //\tHeader 1 //\t======== // //\tHeader 2 //\t-------- // text = text.replace(/^(.+)[ t]*n=+[ t]*n+/gm, function(wholeMatch,m1){return hashBlock('<h1 id=\"' + headerId(m1) + '\">' + _RunSpanGamut(m1) + \"</h1>\");}); text = text.replace(/^(.+)[ t]*n-+[ t]*n+/gm, function(matchFound,m1){return hashBlock('<h2 id=\"' + headerId(m1) + '\">' + _RunSpanGamut(m1) + \"</h2>\");}); // atx-style headers: // # Header 1 // ## Header 2 // ## Header 2 with closing hashes ## // ... // ###### Header 6 // /* text = text.replace(/ ^(#{1,6})\t\t\t\t// $1 = string of #'s [ t]* (.+?)\t\t\t\t\t// $2 = Header text [ t]* #*\t\t\t\t\t\t// optional closing #'s (not counted) n+ /gm, function() {...}); */ text = text.replace(/^(#{1,6})[ t]*(.+?)[ t]*#*n+/gm, function(wholeMatch,m1,m2) { var h_level = m1.length; return hashBlock(\"<h\" + h_level + ' id=\"' + headerId(m2) + '\">' + _RunSpanGamut(m2) + \"</h\" + h_level + \">\"); }); function headerId(m) { return m.replace(/[^w]/g, '').toLowerCase(); } return text; } // This declaration keeps Dojo compressor from outputting garbage: var _ProcessListItems; var _DoLists = function(text) { // // Form HTML ordered (numbered) and unordered (bulleted) lists. // // attacklab: add sentinel to hack around khtml/safari bug: // http://bugs.webkit.org/show_bug.cgi?id=11231 text += \"~0\"; // Re-usable pattern to match any entirel ul or ol list: /* var whole_list = / (\t\t\t\t\t\t\t\t\t// $1 = whole list (\t\t\t\t\t\t\t\t// $2 [ ]{0,3}\t\t\t\t\t// attacklab: g_tab_width - 1 ([*+-]|d+[.])\t\t\t\t// $3 = first list item marker [ t]+ ) [^r]+? (\t\t\t\t\t\t\t\t// $4 ~0\t\t\t\t\t\t\t// sentinel for workaround; should be $ | n{2,} (?=S) (?!\t\t\t\t\t\t\t// Negative lookahead for another list item marker [ t]* (?:[*+-]|d+[.])[ t]+ ) ) )/g */ var whole_list = /^(([ ]{0,3}([*+-]|d+[.])[ t]+)[^r]+?(~0|n{2,}(?=S)(?![ t]*(?:[*+-]|d+[.])[ t]+)))/gm; if (g_list_level) { text = text.replace(whole_list,function(wholeMatch,m1,m2) { var list = m1; var list_type = (m2.search(/[*+-]/g)>-1) ? \"ul\" : \"ol\"; // Turn double returns into triple returns, so that we can make a // paragraph for the last item in a list, if necessary: list = list.replace(/n{2,}/g,\"nnn\");; var result = _ProcessListItems(list); // Trim any trailing whitespace, to put the closing `</$list_type>` // up on the preceding line, to get it past the current stupid // HTML block parser. This is a hack to work around the terrible // hack that is the HTML block parser. result = result.replace(/s+$/,\"\"); result = \"<\"+list_type+\">\" + result + \"</\"+list_type+\">n\"; return result; }); } else { whole_list = /(nn|^n?)(([ ]{0,3}([*+-]|d+[.])[ t]+)[^r]+?(~0|n{2,}(?=S)(?![ t]*(?:[*+-]|d+[.])[ t]+)))/g; text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) { var runup = m1; var list = m2; var list_type = (m3.search(/[*+-]/g)>-1) ? \"ul\" : \"ol\"; // Turn double returns into triple returns, so that we can make a // paragraph for the last item in a list, if necessary: var list = list.replace(/n{2,}/g,\"nnn\");; var result = _ProcessListItems(list); result = runup + \"<\"+list_type+\">n\" + result + \"</\"+list_type+\">n\"; return result; }); } // attacklab: strip sentinel text = text.replace(/~0/,\"\"); return text; } _ProcessListItems = function(list_str) { // // Process the contents of a single ordered or unordered list, splitting it // into individual list items. // // The $g_list_level global keeps track of when we're inside a list. // Each time we enter a list, we increment it; when we leave a list, // we decrement. If it's zero, we're not in a list anymore. // // We do this because when we're not inside a list, we want to treat // something like this: // // I recommend upgrading to version // 8. Oops, now this line is treated // as a sub-list. // // As a single paragraph, despite the fact that the second line starts // with a digit-period-space sequence. // // Whereas when we're inside a list (or sub-list), that line will be // treated as the start of a sub-list. What a kludge, huh? This is // an aspect of Markdown's syntax that's hard to parse perfectly // without resorting to mind-reading. Perhaps the solution is to // change the syntax rules such that sub-lists must start with a // starting cardinal number; e.g. \"1.\" or \"a.\". g_list_level++; // trim trailing blank lines: list_str = list_str.replace(/n{2,}$/,\"n\"); // attacklab: add sentinel to emulate z list_str += \"~0\"; /* list_str = list_str.replace(/ (n)?\t\t\t\t\t\t\t// leading line = $1 (^[ t]*)\t\t\t\t\t\t// leading whitespace = $2 ([*+-]|d+[.]) [ t]+\t\t\t// list marker = $3 ([^r]+?\t\t\t\t\t\t// list item text = $4 (n{1,2})) (?= n* (~0 | 2 ([*+-]|d+[.]) [ t]+)) /gm, function(){...}); */ list_str = list_str.replace(/(n)?(^[ t]*)([*+-]|d+[.])[ t]+([^r]+?(n{1,2}))(?=n*(~0|2([*+-]|d+[.])[ t]+))/gm, function(wholeMatch,m1,m2,m3,m4){ var item = m4; var leading_line = m1; var leading_space = m2; if (leading_line || (item.search(/n{2,}/)>-1)) { item = _RunBlockGamut(_Outdent(item)); } else { // Recursion for sub-lists: item = _DoLists(_Outdent(item)); item = item.replace(/n$/,\"\"); // chomp(item) item = _RunSpanGamut(item); } return \"<li>\" + item + \"</li>n\"; } ); // attacklab: strip sentinel list_str = list_str.replace(/~0/g,\"\"); g_list_level--; return list_str; } var _DoCodeBlocks = function(text) { // // Process Markdown `<pre><code>` blocks. // /* text = text.replace(text, /(?:nn|^) (\t\t\t\t\t\t\t\t// $1 = the code block -- one or more lines, starting with a space/tab (?: (?:[ ]{4}|t)\t\t\t// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width .*n+ )+ ) (n*[ ]{0,3}[^ tn]|(?=~0))\t// attacklab: g_tab_width /g,function(){...}); */ // attacklab: sentinel workarounds for lack of A and Z, safarikhtml bug text += \"~0\"; text = text.replace(/(?:nn|^)((?:(?:[ ]{4}|t).*n+)+)(n*[ ]{0,3}[^ tn]|(?=~0))/g, function(wholeMatch,m1,m2) { var codeblock = m1; var nextChar = m2; codeblock = _EncodeCode( _Outdent(codeblock)); codeblock = _Detab(codeblock); codeblock = codeblock.replace(/^n+/g,\"\"); // trim leading newlines codeblock = codeblock.replace(/n+$/g,\"\"); // trim trailing whitespace codeblock = \"<pre><code>\" + codeblock + \"n</code></pre>\"; return hashBlock(codeblock) + nextChar; } ); // attacklab: strip sentinel text = text.replace(/~0/,\"\"); return text; } var hashBlock = function(text) { text = text.replace(/(^n+|n+$)/g,\"\"); return \"nn~K\" + (g_html_blocks.push(text)-1) + \"Knn\"; } var _DoCodeSpans = function(text) { // // * Backtick quotes are used for <code></code> spans. // // * You can use multiple backticks as the delimiters if you want to //\t include literal backticks in the code span. So, this input: // //\t\t Just type ``foo `bar` baz`` at the prompt. // //\t Will translate to: // //\t\t <p>Just type <code>foo `bar` baz</code> at the prompt.</p> // //\tThere's no arbitrary limit to the number of backticks you //\tcan use as delimters. If you need three consecutive backticks //\tin your code, use four for delimiters, etc. // // * You can use spaces to get literal backticks at the edges: // //\t\t ... type `` `bar` `` ... // //\t Turns to: // //\t\t ... type <code>`bar`</code> ... // /* text = text.replace(/ (^|[^])\t\t\t\t\t// Character before opening ` can't be a backslash (`+)\t\t\t\t\t\t// $2 = Opening run of ` (\t\t\t\t\t\t\t// $3 = The code block [^r]*? [^`]\t\t\t\t\t// attacklab: work around lack of lookbehind ) 2\t\t\t\t\t\t\t// Matching closer (?!`) /gm, function(){...}); */ text = text.replace(/(^|[^])(`+)([^r]*?[^`])2(?!`)/gm, function(wholeMatch,m1,m2,m3,m4) { var c = m3; c = c.replace(/^([ t]*)/g,\"\");\t// leading whitespace c = c.replace(/[ t]*$/g,\"\");\t// trailing whitespace c = _EncodeCode(c); return m1+\"<code>\"+c+\"</code>\"; }); return text; } var _EncodeCode = function(text) { // // Encode/escape certain characters inside Markdown code runs. // The point is that in code, these characters are literals, // and lose their special Markdown meanings. // // Encode all ampersands; HTML entities are not // entities within a Markdown code span. text = text.replace(/&/g,\"&amp;\"); // Do the angle bracket song and dance: text = text.replace(/</g,\"&lt;\"); text = text.replace(/>/g,\"&gt;\"); // Now, escape characters that are magic in Markdown: text = escapeCharacters(text,\"*_{}[]\",false); // jj the line above breaks this: //--- //* Item // 1. Subitem // special char: * //--- return text; } var _DoItalicsAndBold = function(text) { // <strong> must go first: text = text.replace(/(**|__)(?=S)([^r]*?S[*_]*)1/g, \"<strong>$2</strong>\"); text = text.replace(/(*|_)(?=S)([^r]*?S)1/g, \"<em>$2</em>\"); return text; } var _DoBlockQuotes = function(text) { /* text = text.replace(/ (\t\t\t\t\t\t\t\t// Wrap whole match in $1 ( ^[ t]*>[ t]?\t\t\t// '>' at the start of a line .+n\t\t\t\t\t// rest of the first line (.+n)*\t\t\t\t\t// subsequent consecutive lines n*\t\t\t\t\t\t// blanks )+ ) /gm, function(){...}); */ text = text.replace(/((^[ t]*>[ t]?.+n(.+n)*n*)+)/gm, function(wholeMatch,m1) { var bq = m1; // attacklab: hack around Konqueror 3.5.4 bug: // \"----------bug\".replace(/^-/g,\"\") == \"bug\" bq = bq.replace(/^[ t]*>[ t]?/gm,\"~0\");\t// trim one level of quoting // attacklab: clean up hack bq = bq.replace(/~0/g,\"\"); bq = bq.replace(/^[ t]+$/gm,\"\");\t\t// trim whitespace-only lines bq = _RunBlockGamut(bq);\t\t\t\t// recurse bq = bq.replace(/(^|n)/g,\"$1 \"); // These leading spaces screw with <pre> content, so we need to fix that: bq = bq.replace( /(s*<pre>[^r]+?</pre>)/gm, function(wholeMatch,m1) { var pre = m1; // attacklab: hack around Konqueror 3.5.4 bug: pre = pre.replace(/^ /mg,\"~0\"); pre = pre.replace(/~0/g,\"\"); return pre; }); return hashBlock(\"<blockquote>n\" + bq + \"n</blockquote>\"); }); return text; } var _FormParagraphs = function(text) { // // Params: // $text - string to process with html <p> tags // // Strip leading and trailing lines: text = text.replace(/^n+/g,\"\"); text = text.replace(/n+$/g,\"\"); var grafs = text.split(/n{2,}/g); var grafsOut = new Array(); // // Wrap <p> tags. // var end = grafs.length; for (var i=0; i<end; i++) { var str = grafs[i]; // if this is an HTML marker, copy it if (str.search(/~K(d+)K/g) >= 0) { grafsOut.push(str); } else if (str.search(/S/) >= 0) { str = _RunSpanGamut(str); str = str.replace(/^([ t]*)/g,\"<p>\"); str += \"</p>\" grafsOut.push(str); } } // // Unhashify HTML blocks // end = grafsOut.length; for (var i=0; i<end; i++) { // if this is a marker for an html block... while (grafsOut[i].search(/~K(d+)K/) >= 0) { var blockText = g_html_blocks[RegExp.$1]; blockText = blockText.replace(/$/g,\"$$$$\"); // Escape any dollar signs grafsOut[i] = grafsOut[i].replace(/~Kd+K/,blockText); } } return grafsOut.join(\"nn\"); } var _EncodeAmpsAndAngles = function(text) { // Smart processing for ampersands and angle brackets that need to be encoded. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: // http://bumppo.net/projects/amputator/ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|w+);)/g,\"&amp;\"); // Encode naked <'s text = text.replace(/<(?![a-z/?$!])/gi,\"&lt;\"); return text; } var _EncodeBackslashEscapes = function(text) { // // Parameter: String. // Returns:\tThe string, with after processing the following backslash //\t\t\t escape sequences. // // attacklab: The polite way to do this is with the new // escapeCharacters() function: // // \ttext = escapeCharacters(text,\"\",true); // \ttext = escapeCharacters(text,\"`*_{}[]()>#+-.!\",true); // // ...but we're sidestepping its use of the (slow) RegExp constructor // as an optimization for Firefox. This function gets called a LOT. text = text.replace(/()/g,escapeCharacters_callback); text = text.replace(/([`*_{}[]()>#+-.!])/g,escapeCharacters_callback); return text; } var _DoAutoLinks = function(text) { text = text.replace(/<((https?|ftp|dict):[^'\">s]+)>/gi,\"<a href=\"$1\">$1</a>\"); // Email addresses: <[email protected]> /* text = text.replace(/ < (?:mailto:)? ( [-.w]+ @ [-a-z0-9]+(.[-a-z0-9]+)*.[a-z]+ ) > /gi, _DoAutoLinks_callback()); */ text = text.replace(/<(?:mailto:)?([-.w]+@[-a-z0-9]+(.[-a-z0-9]+)*.[a-z]+)>/gi, function(wholeMatch,m1) { return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); } ); return text; } var _EncodeEmailAddress = function(addr) { // // Input: an email address, e.g. \"[email protected]\" // // Output: the email address as a mailto link, with each character //\tof the address encoded as either a decimal or hex entity, in //\tthe hopes of foiling most address harvesting spam bots. E.g.: // //\t<a href=\"&#x6D;&#97;&#105;&#108;&#x74;&#111;:&#102;&#111;&#111;&#64;&#101; //\t x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;\">&#102;&#111;&#111; //\t &#64;&#101;x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;</a> // // Based on a filter by Matthew Wickline, posted to the BBEdit-Talk // mailing list: <http://tinyurl.com/yu7ue> // // attacklab: why can't javascript speak hex? function char2hex(ch) { var hexDigits = '0123456789ABCDEF'; var dec = ch.charCodeAt(0); return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15)); } var encode = [ function(ch){return \"&#\"+ch.charCodeAt(0)+\";\";}, function(ch){return \"&#x\"+char2hex(ch)+\";\";}, function(ch){return ch;} ]; addr = \"mailto:\" + addr; addr = addr.replace(/./g, function(ch) { if (ch == \"@\") { // this *must* be encoded. I insist. ch = encode[Math.floor(Math.random()*2)](ch); } else if (ch !=\":\") { // leave ':' alone (to spot mailto: later) var r = Math.random(); // roughly 10% raw, 45% hex, 45% dec ch = ( r > .9 ?\tencode[2](ch) : r > .45 ?\tencode[1](ch) : encode[0](ch) ); } return ch; }); addr = \"<a href=\"\" + addr + \"\">\" + addr + \"</a>\"; addr = addr.replace(/\">.+:/g,\"\">\"); // strip the mailto: from the visible part return addr; } var _UnescapeSpecialChars = function(text) { // // Swap back in all the special characters we've hidden. // text = text.replace(/~E(d+)E/g, function(wholeMatch,m1) { var charCodeToReplace = parseInt(m1); return String.fromCharCode(charCodeToReplace); } ); return text; } var _Outdent = function(text) { // // Remove one level of line-leading tabs or spaces // // attacklab: hack around Konqueror 3.5.4 bug: // \"----------bug\".replace(/^-/g,\"\") == \"bug\" text = text.replace(/^(t|[ ]{1,4})/gm,\"~0\"); // attacklab: g_tab_width // attacklab: clean up hack text = text.replace(/~0/g,\"\") return text; } var _Detab = function(text) { // attacklab: Detab's completely rewritten for speed. // In perl we could fix it by anchoring the regexp with G. // In javascript we're less fortunate. // expand first n-1 tabs text = text.replace(/t(?=t)/g,\" \"); // attacklab: g_tab_width // replace the nth with two sentinels text = text.replace(/t/g,\"~A~B\"); // use the sentinel to anchor our regex so it doesn't explode text = text.replace(/~B(.+?)~A/g, function(wholeMatch,m1,m2) { var leadingText = m1; var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width // there *must* be a better way to do this: for (var i=0; i<numSpaces; i++) leadingText+=\" \"; return leadingText; } ); // clean up sentinels text = text.replace(/~A/g,\" \"); // attacklab: g_tab_width text = text.replace(/~B/g,\"\"); return text; } // // attacklab: Utility functions // var escapeCharacters = function(text, charsToEscape, afterBackslash) { // First we have to escape the escape characters so that // we can build a character class out of them var regexString = \"([\" + charsToEscape.replace(/([[]])/g,\"$1\") + \"])\"; if (afterBackslash) { regexString = \"\" + regexString; } var regex = new RegExp(regexString,\"g\"); text = text.replace(regex,escapeCharacters_callback); return text; } var escapeCharacters_callback = function(wholeMatch,m1) { var charCodeToEscape = m1.charCodeAt(0); return \"~E\"+charCodeToEscape+\"E\"; } } // end of Showdown.converter // export if (typeof exports != 'undefined') exports.Showdown = Showdown; </del> No newline at end of file", "commid": "react_pr_3663"}], "negative_passages": []}
{"query_id": "q-en-react-795741901fb82091b7a486876f357df0a3316ec909e9dfe8a9ecdec72a57a791", "query": "Calling on in a component being Shallow Rendered will result in the error being thrown. I set up a test case:\nWho would be best to answer this one?\nSeems like a valid bug report \u2014 thanks and the test case is rad. I may not be able to look at this for a while, unfortunately.\nno worries let me know if you need any more info from me. This was on React 14 beta btw (not sure if that matters)\nI have the same issue. A simpler example that throws the error:\nAny way of getting around this issue? I am currently running into it.\nSorry about the slow response from us (FB) here. I'm the principal author of the shallow render feature, but React core isn't my main gig and I've been swamped with product work. I don't have an offhand answer for you, but I've just put time on my calendar to look into this next week. Jim, Ben, Paul \u2014 if by chance one of you happened to take care of this before then, I wouldn't be mad :)\nAn update on my end. I think that my problem actually went away when I deduped my npm dependencies to remove an extra react version that was causing issues. If this error pops up again I'll let you know. Thanks for the response! On Fri, Aug 28, 2015, 9:38 PM Scott Feeney wrote:\nHmm I am still able to reproduce this issue in my test case after running npm dedupe\nJust to clarify, my previous comment wasn't supposed to mean that the issue has gone away. I think I was seeing a separate issue caused by multiple react versions that I misidentified as this issue (I hope that makes sense).\nI am getting this error, too. I'm using react v0.14.0-rc1. Looking at the code : Apparently .\nNote that shallow rendered components override to return a instead of whatever it normally returns. That still shouldn't be undefined and should have a attribute, though.\nI'm experiencing this issue too - your suggestion gets me past the initial error & on to in\nPretty sure this breaks many other things outside of , but I noticed moving to be directly above in fixed this for me.\nWe are also affected by this issue. I think shallow rendering is a really cool feature for testing, but unfortunately I can't use it for some of our components due to this bug.\nI created pull request with a fix that works for me. Can someone else verify?\nAny workaround for this issue?\n:+1: Having same issue\nJust ran into this too :/\nAny update on this? I see that 0.14.3 was released, but these kind of tests are still failing.\nI think I have to add a test to my pull request before it can be merged, but I did not get around to do it yet.\nClosing in favor of which should merge soon.", "positive_passages": [{"docid": "doc-en-react-5ad035ad18a9a4e413908b84058063bb2d78ef427b0c8bda49a2e77301cb9a4a", "text": "if (!context) { context = emptyObject; } <del> var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true); this._render(element, transaction, context); ReactUpdates.ReactReconcileTransaction.release(transaction); </del> <ins> ReactUpdates.batchedUpdates(_batchedRender, this, element, context); </ins> return this.getRenderOutput(); }; <ins> function _batchedRender(renderer, element, context) { var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true); renderer._render(element, transaction, context); ReactUpdates.ReactReconcileTransaction.release(transaction); } </ins> ReactShallowRenderer.prototype.getRenderOutput = function() { return ( (this._instance && this._instance._renderedComponent &&", "commid": "react_pr_5561"}], "negative_passages": []}
{"query_id": "q-en-react-795741901fb82091b7a486876f357df0a3316ec909e9dfe8a9ecdec72a57a791", "query": "Calling on in a component being Shallow Rendered will result in the error being thrown. I set up a test case:\nWho would be best to answer this one?\nSeems like a valid bug report \u2014 thanks and the test case is rad. I may not be able to look at this for a while, unfortunately.\nno worries let me know if you need any more info from me. This was on React 14 beta btw (not sure if that matters)\nI have the same issue. A simpler example that throws the error:\nAny way of getting around this issue? I am currently running into it.\nSorry about the slow response from us (FB) here. I'm the principal author of the shallow render feature, but React core isn't my main gig and I've been swamped with product work. I don't have an offhand answer for you, but I've just put time on my calendar to look into this next week. Jim, Ben, Paul \u2014 if by chance one of you happened to take care of this before then, I wouldn't be mad :)\nAn update on my end. I think that my problem actually went away when I deduped my npm dependencies to remove an extra react version that was causing issues. If this error pops up again I'll let you know. Thanks for the response! On Fri, Aug 28, 2015, 9:38 PM Scott Feeney wrote:\nHmm I am still able to reproduce this issue in my test case after running npm dedupe\nJust to clarify, my previous comment wasn't supposed to mean that the issue has gone away. I think I was seeing a separate issue caused by multiple react versions that I misidentified as this issue (I hope that makes sense).\nI am getting this error, too. I'm using react v0.14.0-rc1. Looking at the code : Apparently .\nNote that shallow rendered components override to return a instead of whatever it normally returns. That still shouldn't be undefined and should have a attribute, though.\nI'm experiencing this issue too - your suggestion gets me past the initial error & on to in\nPretty sure this breaks many other things outside of , but I noticed moving to be directly above in fixed this for me.\nWe are also affected by this issue. I think shallow rendering is a really cool feature for testing, but unfortunately I can't use it for some of our components due to this bug.\nI created pull request with a fix that works for me. Can someone else verify?\nAny workaround for this issue?\n:+1: Having same issue\nJust ran into this too :/\nAny update on this? I see that 0.14.3 was released, but these kind of tests are still failing.\nI think I have to add a test to my pull request before it can be merged, but I did not get around to do it yet.\nClosing in favor of which should merge soon.", "positive_passages": [{"docid": "doc-en-react-3254a23f86d127eb63cb4fb31cd7a2ad33f0e948cb50c4f3065100a7118a5f8e", "text": "expect(result.props.className).toEqual('clicked'); }); <ins> it('can setState in componentWillMount when shallow rendering', function() { var SimpleComponent = React.createClass({ componentWillMount() { this.setState({groovy: 'doovy'}); }, render() { return <div>{this.state.groovy}</div>; }, }); var shallowRenderer = ReactTestUtils.createRenderer(); var result = shallowRenderer.render(<SimpleComponent />); expect(result).toEqual(<div>doovy</div>); }); </ins> it('can pass context when shallowly rendering', function() { var SimpleComponent = React.createClass({ contextTypes: {", "commid": "react_pr_5561"}], "negative_passages": []}
{"query_id": "q-en-react-1def5d8af304d4cceb1351c6e7c9af25c0fb6336e4edda68a67920ef2caca0bc", "query": "I'm trying to use the attribute as described here: Unfortunately, sometimes returns , when is called multiple times. MWE:\nThis is intended \u2013 when the component is unmounted or the ref changes, the old ref gets called with null before it's called with the new value (or the same component instance again). If you store the instance on your component, this effect should be unobservable as long as your component is mounted, but it prevents memory leaks. If you want to do something with in the ref handler, you should check if it's null.\nThanks for the information! I think this might be worth mentioning in the docs.", "positive_passages": [{"docid": "doc-en-react-f9d164a4a2c41f939211fc8c276c93667997e4272ced4685230610b3a8a9731a", "text": "1. Assign a `ref` attribute to anything returned from `render` such as: <del> ```html <input ref=\"myInput\" /> ``` </del> <ins> ```html <input ref=\"myInput\" /> ``` </ins> 2. In some other code (typically event handler code), access the **backing instance** via `this.refs` as in: <del> ```javascript this.refs.myInput ``` </del> <ins> ```javascript this.refs.myInput ``` </ins> You can access the component's DOM node directly by calling `React.findDOMNode(this.refs.myInput)`.", "commid": "react_pr_4664"}], "negative_passages": []}
{"query_id": "q-en-react-1def5d8af304d4cceb1351c6e7c9af25c0fb6336e4edda68a67920ef2caca0bc", "query": "I'm trying to use the attribute as described here: Unfortunately, sometimes returns , when is called multiple times. MWE:\nThis is intended \u2013 when the component is unmounted or the ref changes, the old ref gets called with null before it's called with the new value (or the same component instance again). If you store the instance on your component, this effect should be unobservable as long as your component is mounted, but it prevents memory leaks. If you want to do something with in the ref handler, you should check if it's null.\nThanks for the information! I think this might be worth mentioning in the docs.", "positive_passages": [{"docid": "doc-en-react-3c6a06f44e410510877b85ff85d9a7aeedb7fe44f349894d108971ebb8594571", "text": "It's as simple as assigning a `ref` attribute to anything returned from `render` such as: <del> ```html <input ref={ function(component){ React.findDOMNode(component).focus();} } /> ``` </del> <ins> ```html render: function() { return <TextInput ref={(c) => this._input = c} } />; }, componentDidMount: function() { this._input.focus(); }, ``` or ```html render: function() { return ( <TextInput ref={function(input) { if (input != null) { input.focus(); } }} /> ); }, ``` Note that when the referenced component is unmounted and whenever the ref changes, the old ref will be called with `null` as an argument. This prevents memory leaks in the case that the instance is stored, as in the first example. Note that when writing refs with inline function expressions as in the examples here, React sees a different function object each time so on every update, ref will be called with `null` immediately before it's called with the component instance. </ins> ## Completing the Example", "commid": "react_pr_4664"}], "negative_passages": []}
{"query_id": "q-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "query": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "positive_passages": [{"docid": "doc-en-react-dbd19929f33e758017c96fcd0647db2a637832924b640b1cfd30732c8d156bbe", "text": "* @param {*} parentType node's parent's type. */ function validateChildKeys(node, parentType) { <ins> if (typeof node !== 'object') { return; } </ins> if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i];", "commid": "react_pr_4823"}], "negative_passages": []}
{"query_id": "q-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "query": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "positive_passages": [{"docid": "doc-en-react-a16d084bfe68f2f91f3fb88388c4a1abb2300f395e049656f487a78845a3a100", "text": "expect(console.error.argsForCall.length).toBe(0); }); <ins> it('should not enumerate enumerable numbers (#4776)', function() { /*eslint-disable no-extend-native */ Number.prototype['@@iterator'] = function() { throw new Error('number iterator called'); }; /*eslint-enable no-extend-native */ try { void ( <div> {5} {12} {13} </div> ); } finally { delete Number.prototype['@@iterator']; } }); </ins> });", "commid": "react_pr_4823"}], "negative_passages": []}
{"query_id": "q-en-react-e67de791693db938af10b78c2ee6743684ef35b812d1374870cdb39182ae80b2", "query": "Issue with the reproducible example . Full build contains non-standard iterator. Theoretical, it can be to ES in the future, it can be (or already ) to another libraries. should take into account possibility iterable numbers.\nWell, the good news is that if this is already on enough pages, then introducing iterable numbers may not be web compatible anyway. I think that this is only in DEV only code. Unfortunately a lot of pages incorrectly uses the DEV build of React.\n\"good news\"", "positive_passages": [{"docid": "doc-en-react-7dc7a35ee6bbd0b5ab9b398962b134075cba411420398775f54f389be456d4e5", "text": "); }); <ins> it('should not enumerate enumerable numbers (#4776)', function() { /*eslint-disable no-extend-native */ Number.prototype['@@iterator'] = function() { throw new Error('number iterator called'); }; /*eslint-enable no-extend-native */ try { var instance = ( <div> {5} {12} {13} </div> ); var traverseFn = jasmine.createSpy(); traverseAllChildren(instance.props.children, traverseFn, null); expect(traverseFn.calls.length).toBe(3); expect(traverseFn).toHaveBeenCalledWith( null, 5, '.0' ); expect(traverseFn).toHaveBeenCalledWith( null, 12, '.1' ); expect(traverseFn).toHaveBeenCalledWith( null, 13, '.2' ); } finally { delete Number.prototype['@@iterator']; } }); </ins> });", "commid": "react_pr_4823"}], "negative_passages": []}
{"query_id": "q-en-react-c5fdcaf06bf83f9011e0945d502600fbda0b23da3dda3cc70ca0b979475789b1", "query": "I'm still quite new to React, but I guess this is a bug in the React framework introduced in 0.14. Seems like all listeners attached with JSX are broken in native Android browser for Android LTE 4.3, when compiling code with NODEENV development. Everything works fine with NODEENV production compilation. I've tracked it down to being related to ReactErrorUtils, that in development mode do guards on events. The source code: If I simply remove that part of code after compiling the React app, the listeners starts working again. I guess this is not intentional, but instead a bug? To reproduce problem in Android LTE 4.3 (code that works in e.g. Chrome Browser): Using the pre-compiled Getting Started lib\nHm. That's unfortunate. I guess we'll try to find a feature test for this and patch it.", "positive_passages": [{"docid": "doc-en-react-4fac6b6e044cd45c65f21975a0980224f8a6c66340830a75ffb5bb5174bb7ffe", "text": "* real browser event. */ if (typeof window !== 'undefined' && <del> typeof window.dispatchEvent === 'function' && typeof Event === 'function') { </del> <ins> typeof window.dispatchEvent === 'function') { </ins> var fakeNode = document.createElement('react'); ReactErrorUtils.invokeGuardedCallback = function(name, func, a, b) { var boundFunc = func.bind(null, a, b); fakeNode.addEventListener(name, boundFunc, false); <del> fakeNode.dispatchEvent(new Event(name)); </del> <ins> var evt = document.createEvent('Event'); evt.initEvent(name, false, false); fakeNode.dispatchEvent(evt); </ins> fakeNode.removeEventListener(name, boundFunc, false); }; }", "commid": "react_pr_5157"}], "negative_passages": []}
{"query_id": "q-en-react-c2a3cc3ca43cfe1a4652396cfc14adfa6f68aff3900143c7249698f9178b404e", "query": "Oddly enough, the two examples below are not equal as I thought they would be. The error is as follows: I'm assuming that is because the function as assuming an optional callback. But I would expect your code to do a typeof check, and not just a defined check. Can we change it to do a check? I can submit a PR.\nWell, the typecheck happens with that exact typecheck, just not directly in forceupdate. Here's forceUpdate: and where the invariant happens: FWIW, is not the same as due to an important distinction. The former makes a new function that is bound but it will pass along any arguments. The latter also is a new function but it explicitly doesn't pass any arguments. So the former gets the event passed along while the latter just drops it. The event isn't callable, thus the invariant. We need to do the typecheck so I guess we could discuss whether we keep it as an invariant or a warning. But it is a misuse of the API.\nTo follow up on that, the more \"equal\" thing would be: Which should throw the same error that you see with your first bind example.\nCorrect. Yes, I understand all of that. It wasn't toooo hard for me to understand what is happening. And it is a misuse of the API. So I guess, I would consider adding the argument type to the invariant to help make it clearer? Something more like: It's kind of moot. But It confused me for a second. Might confuse others also.", "positive_passages": [{"docid": "doc-en-react-d7c85deab10b3e9127ea12199d4edd03abb25c028c0a29cd022bc538290985a9", "text": "invariant( typeof callback === 'function', 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + <del> '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn't callable.' </del> <ins> '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' + '%s. A function is expected', typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ? typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback </ins> ); var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);", "commid": "react_pr_5193"}], "negative_passages": []}
{"query_id": "q-en-react-c2a3cc3ca43cfe1a4652396cfc14adfa6f68aff3900143c7249698f9178b404e", "query": "Oddly enough, the two examples below are not equal as I thought they would be. The error is as follows: I'm assuming that is because the function as assuming an optional callback. But I would expect your code to do a typeof check, and not just a defined check. Can we change it to do a check? I can submit a PR.\nWell, the typecheck happens with that exact typecheck, just not directly in forceupdate. Here's forceUpdate: and where the invariant happens: FWIW, is not the same as due to an important distinction. The former makes a new function that is bound but it will pass along any arguments. The latter also is a new function but it explicitly doesn't pass any arguments. So the former gets the event passed along while the latter just drops it. The event isn't callable, thus the invariant. We need to do the typecheck so I guess we could discuss whether we keep it as an invariant or a warning. But it is a misuse of the API.\nTo follow up on that, the more \"equal\" thing would be: Which should throw the same error that you see with your first bind example.\nCorrect. Yes, I understand all of that. It wasn't toooo hard for me to understand what is happening. And it is a misuse of the API. So I guess, I would consider adding the argument type to the invariant to help make it clearer? Something more like: It's kind of moot. But It confused me for a second. Might confuse others also.", "positive_passages": [{"docid": "doc-en-react-f086e61118df133782bdc4dd227f820bf385fe078fb698f61896d7dd090bc3b6", "text": "invariant( typeof callback === 'function', 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + <del> '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn't callable.' </del> <ins> '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' + '%s. A function is expected', typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ? typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback </ins> ); if (internalInstance._pendingCallbacks) { internalInstance._pendingCallbacks.push(callback);", "commid": "react_pr_5193"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-16718054d599960fb547cad39f0c28c62dc62abbf70ae84fa52bad93c51f61eb", "text": "*/ function createLinkTypeChecker(linkType) { var shapes = { <del> value: typeof linkType === 'undefined' ? </del> <ins> value: linkType === undefined ? </ins> React.PropTypes.any.isRequired : linkType.isRequired, requestChange: React.PropTypes.func.isRequired,", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-60af45ec1f480055eb1da3aa72b1b6bee7c170264b9ca5e258208a4c701ce06e", "text": "var initialState = this.getInitialState ? this.getInitialState() : null; if (__DEV__) { // We allow auto-mocks to proceed as if they're returning null. <del> if (typeof initialState === 'undefined' && </del> <ins> if (initialState === undefined && </ins> this.getInitialState._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience.", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-4303336dbe20c3151c6ec21af764ec55a88d5af7c27417a68dbe1b7af1dde83a", "text": "if (type && type.defaultProps) { var defaultProps = type.defaultProps; for (propName in defaultProps) { <del> if (typeof props[propName] === 'undefined') { </del> <ins> if (props[propName] === undefined) { </ins> props[propName] = defaultProps[propName]; } }", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-525b5ea24f395571732d5a3b24f3c928eb3ee2772bc0f40ce891fdd7916b784f", "text": "var range = document.selection.createRange().duplicate(); var start, end; <del> if (typeof offsets.end === 'undefined') { </del> <ins> if (offsets.end === undefined) { </ins> start = offsets.start; end = start; } else if (offsets.start > offsets.end) {", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-797989d816390e62cad5af1a74efbaa513c6d5a954f9400ea09c415dfbba982b", "text": "var selection = window.getSelection(); var length = node[getTextContentAccessor()].length; var start = Math.min(offsets.start, length); <del> var end = typeof offsets.end === 'undefined' ? </del> <ins> var end = offsets.end === undefined ? </ins> start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method.", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-16e6dfb06fc612e47a4fda361c5e5e78919b4bd19f2a6af595b015f7188b167b", "text": "setSelection: function(input, offsets) { var start = offsets.start; var end = offsets.end; <del> if (typeof end === 'undefined') { </del> <ins> if (end === undefined) { </ins> end = start; }", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-e9c7c9063ed3379443aa17d427434c8c3fe1a3eabb11ff94c3ee243651c7c899", "text": "Component.displayName || Component.name || 'Component'; warning( <del> typeof inst.props === 'undefined' || !propsMutated, </del> <ins> inst.props === undefined || !propsMutated, </ins> '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component's constructor was passed.', componentName, componentName", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-1a52540bee65855f0ee1d5bdd24a06bfdf2ba93b15fbb9f3cb5744a494ed42c1", "text": "if (__DEV__) { warning( <del> typeof shouldUpdate !== 'undefined', </del> <ins> shouldUpdate !== undefined, </ins> '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent'", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-ebfcb743aff813e9c4529ab43570cce674092783fd3ef9a2cd7ff39596fc8553", "query": "Introduction I found a bug on resolving default props when component props have property with HTMLAllCollection. React ignores value and uses default value (it should take that collection). isIE9OrLower (look at the end of topic) is simple function to test Internet Explorer in version 9 or lower. Simple use case: Chrome/Firefox/modern IE (yeah, i know....) returns HTMLAllColection (as ), but old IE returns true. HTMLAllCollection is weird collection: Source of bug and fix release: 0.14.7 file: line: 9149 code (bug): if (typeof props[propName] === 'undefined') { code (fix): if (props[propName] === undefined) { Btw, === undefined is faster than typeof === 'undefined' on Chrome and IE. Reproduction Open in Firefox / Chrome / IE10 or higher. Fiddle: Raw: Workaround Change to\nHaha, browsers suck. Want to submit a PR? It looks like we do that thing unnecessarily in a few places in the React codebase. Note that we do need to use typeof if the binding might not exist, so we need to look at each case individually to make sure the change is valid there.\nI went through the react repo configuration (build, tests execution). Fix didn't break anything, but so far I didn't find solution to make good test (phantomjs doesn't have property). (HTMLAllCollection) is probably the only exception to the typeof and is not a html standard. Any suggestions to the unit test for this fix/improvement?\nAs long as you tested it manually and it worked in IE, I think we can accept this change without a unit test.\nFixed in\nlol what even\nI can't reproduce being in IE 8 or IE 9 on Windows 7, either in standards or quirks mode. What am I missing?\nIE < 10 is fine. Problem occurs when using modern browser like Chrome, Firefox, IE = 10 or Edge. They returns . component prop as in Chrome. will compare your prop with default prop (which is ). on Chrome is so React treats it as missing value. Default prop () will be selected. the end, prop will be always set to on modern browser in this case.\nOh! Sorry I totally misread. Yes I can repro this.", "positive_passages": [{"docid": "doc-en-react-d863a1f621824d3cc26b604100087f233debf571a19bb2b9f32f80ce469692b9", "text": "var renderedComponent = inst.render(); if (__DEV__) { // We allow auto-mocks to proceed as if they're returning null. <del> if (typeof renderedComponent === 'undefined' && </del> <ins> if (renderedComponent === undefined && </ins> inst.render._isMockFunction) { // This is probably bad practice. Consider warning here and // deprecating this convenience.", "commid": "react_pr_5965"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-8ba2e753847667907bafc3c0a7f72176b3dc917fd07af1855359d8cb779fcb82", "text": "'use strict'; <del> // NOTE: We're explicitly not using JSX in this file. This is intended to test // classic JS without JSX. </del> var React; var ReactDOM; var ReactTestUtils;", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-fabad33f48c0e52e8d12a128cf490c1d9f7284e27fe7c057f17631ac4758408e", "text": "React = require('React'); ReactDOM = require('ReactDOM'); ReactTestUtils = require('ReactTestUtils'); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> ComponentClass = React.createClass({ render: function() { return React.createElement('div');", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-ab6a59e560d4a38796cbf0ecefb8f54ec6e62677f75c9b558bcd1aed86aaa231", "text": "expect(console.error.argsForCall.length).toBe(0); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('allows static methods to be called using the type property', function() { spyOn(console, 'error');", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-e7296faeb4c599cca5f493db1a0b2920ed0d817d761da536e0feaa8aab8ba49c", "text": "expect(console.error.argsForCall.length).toBe(0); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('identifies valid elements', function() { var Component = React.createClass({ render: function() {", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-64209b247f6afc5147a98856632f95f25e01ee8702aceb933b2e72118d238d0d", "text": "expect(typeof Component.specialType.isRequired).toBe('function'); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('is indistinguishable from a plain object', function() { var element = React.createElement('div', {className: 'foo'}); var object = {}; expect(element.constructor).toBe(object.constructor); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('should use default prop value when removing a prop', function() { var Component = React.createClass({ getDefaultProps: function() {", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-8ae28a8f472ffe10d2a8836e6342fd2a29f611d02cfab24abe965c2fb4638421", "text": "expect(instance.props.fruit).toBe('persimmon'); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('should normalize props with default values', function() { var Component = React.createClass({ getDefaultProps: function() {", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-32d61b30277c185f7229705afa6b94f0b47d1322e084100863712b1625ad5cd2", "query": "The have this at the beginning: But there're a number of instances of JSX in the file. For example, . the note be removed or clarified? JSX be purged from the file? adding tests to this file should they be free of JSX? In certain contexts but not others?\nNormally, our style is to use jsx within tests. I think some of the tests explicitly aren't using jsx, and that's the point. Perhaps it would be better to copy-paste that message into each of the tests that doesn't use jsx, since it's easy to miss the note up at the top and having the note at the top is somewhat ambiguous.\nThanks for the feedback. Yeah, for both of those reasons I'd say :+1: to either that or splitting it into two files if that made sense to you (would help with the ease of missing it if it's just at the top and make the alternative of repeating it within the file unnecessary): .\nI'd be happy to submit a PR for either of these cases!\nI think I prefer having the inline comment copy-pasted. A little copy-pasting never hurt anyone (). I'd take a PR for this, assuming no one else objects.", "positive_passages": [{"docid": "doc-en-react-8d8776f60a0c68e6595b528aa24ecfb4546b87995510e0d336939187e0334699", "text": "expect(console.error.argsForCall.length).toBe(0); }); <ins> // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. </ins> it('identifies elements, but not JSON, if Symbols are supported', function() { // Rudimentary polyfill // Once all jest engines support Symbols natively we can swap this to test", "commid": "react_pr_6159"}], "negative_passages": []}
{"query_id": "q-en-react-7105d41f53f0318f45440b370c4bc8358501f54011301facb4e1bf93cf13e422", "query": "(I am using 15rc2 because I need all the svg tags) I am rendering a foreignObject svg tag. According to I put body tag inside that tag and then whatever html I want in there. renderToString on the server leaves the body tag in place, and gives it a react-dataid. However when rendered on the client that body tag is removed. So when I look at the live elements, the body inside foreignObjects is gone, along with it's data-reactid. The server source ( ie view page source ) shows that the body tag was rendered with the missing react-dataid. The result is that you get a \u201cInvariant Violation: Unable to find element with ID XX\u201d, when the page updates, and somethings don't work. Removing the body from inside the foreignObject tag seems to solve the problem, but I don't know if that is an \"OK\" solution to this or if that body tag is necessary in some scenarios. But in either case this seems to be a scenario where server rendering results in different DOM/HTML then client rendering. Is this a problem, or is the body tag not supposed to there anyway? Todd\nWe never render the on the client side - only on the server side. Can you provide a jsfiddle that demonstrates the invariant violation?\nThanks for tracking down more specifically. Could be that browsers don't actually support that body usage? Or when actually parsed from markup, the body node doesn't exist (which seems likely and matches up with what we see in other situations where the browser changes markup). I won't have a chance to look into this more for a few days - it might be best to just use your alternate approach for now.\nI can remove the body tag. It seems to work ok with out it. Whats clear at this point is that if the server sends the body tag, it is not parsed into a DOM node, at least on mac with Chrome and Safari. That results in the error, since the data-reactid for the body is missing. IE doesn't support foreignObject so its not relevant there. MS Edge does, but I haven't tested it.\nIt seems so. Even without React, I can\u2019t get Chrome (or Firefox for that matter) to make an actual node: <img width=\"261\" alt=\"screen shot 2016-03-17 at 15 19 30\" src=\"\"\nFWIW, does manage to put one in:\nSounds like we should add this to : we should warn and tell you you can't put a body tag inside foreignObject. We don't do anything much for SVG there right now; probably the ideal solution would be to pass the namespace info down too, then we can distinguish SVG and HTML tags with the same name (like title), then make sure the contents of a SVG tag are appropriate HTML tags. Not sure which HTML tags are and aren't allowed but it might be detailed in the HTML5 spec at\nCan I take this one?\nplease do :-)", "positive_passages": [{"docid": "doc-en-react-a074fec56e8a7f1d66581e1f0033b1740db91bedec670770ce4ecfa400c9d57f", "text": "expect(isTagStackValid(['table', 'tr'])).toBe(false); expect(isTagStackValid(['div', 'ul', 'li', 'div', 'li'])).toBe(false); expect(isTagStackValid(['div', 'html'])).toBe(false); <ins> expect(isTagStackValid(['body', 'body'])).toBe(false); expect(isTagStackValid(['svg', 'foreignObject', 'body', 'p'])).toBe(false); </ins> }); });", "commid": "react_pr_6469"}], "negative_passages": []}
{"query_id": "q-en-react-7105d41f53f0318f45440b370c4bc8358501f54011301facb4e1bf93cf13e422", "query": "(I am using 15rc2 because I need all the svg tags) I am rendering a foreignObject svg tag. According to I put body tag inside that tag and then whatever html I want in there. renderToString on the server leaves the body tag in place, and gives it a react-dataid. However when rendered on the client that body tag is removed. So when I look at the live elements, the body inside foreignObjects is gone, along with it's data-reactid. The server source ( ie view page source ) shows that the body tag was rendered with the missing react-dataid. The result is that you get a \u201cInvariant Violation: Unable to find element with ID XX\u201d, when the page updates, and somethings don't work. Removing the body from inside the foreignObject tag seems to solve the problem, but I don't know if that is an \"OK\" solution to this or if that body tag is necessary in some scenarios. But in either case this seems to be a scenario where server rendering results in different DOM/HTML then client rendering. Is this a problem, or is the body tag not supposed to there anyway? Todd\nWe never render the on the client side - only on the server side. Can you provide a jsfiddle that demonstrates the invariant violation?\nThanks for tracking down more specifically. Could be that browsers don't actually support that body usage? Or when actually parsed from markup, the body node doesn't exist (which seems likely and matches up with what we see in other situations where the browser changes markup). I won't have a chance to look into this more for a few days - it might be best to just use your alternate approach for now.\nI can remove the body tag. It seems to work ok with out it. Whats clear at this point is that if the server sends the body tag, it is not parsed into a DOM node, at least on mac with Chrome and Safari. That results in the error, since the data-reactid for the body is missing. IE doesn't support foreignObject so its not relevant there. MS Edge does, but I haven't tested it.\nIt seems so. Even without React, I can\u2019t get Chrome (or Firefox for that matter) to make an actual node: <img width=\"261\" alt=\"screen shot 2016-03-17 at 15 19 30\" src=\"\"\nFWIW, does manage to put one in:\nSounds like we should add this to : we should warn and tell you you can't put a body tag inside foreignObject. We don't do anything much for SVG there right now; probably the ideal solution would be to pass the namespace info down too, then we can distinguish SVG and HTML tags with the same name (like title), then make sure the contents of a SVG tag are appropriate HTML tags. Not sure which HTML tags are and aren't allowed but it might be detailed in the HTML5 spec at\nCan I take this one?\nplease do :-)", "positive_passages": [{"docid": "doc-en-react-e98530b7b9d0f3bd4961a7110ba9b95c64d37e09f6f2093d931cb0a5461fe7d1", "text": "case 'rt': return impliedEndTags.indexOf(parentTag) === -1; <ins> case 'body': </ins> case 'caption': case 'col': case 'colgroup':", "commid": "react_pr_6469"}], "negative_passages": []}
{"query_id": "q-en-react-3d98ae18f9257a516b9db4fe9f78cf6bbef3f1800e1fd3c1d3d3398c954d179e", "query": "Identical app. I call after the app is loaded. React 0.14.7: <img width=\"622\" alt=\"screen shot 2016-03-17 at 20 31 56\" src=\"\"React 15.0 RC1, RC2 and master: <img width=\"635\" alt=\"screen shot 2016-03-17 at 20 34 02\" src=\"\"We should fix this before releasing 15.0.\nThere seem to be two distinct things causing this issue: is now a possible argument for and points to DOM nodes which now have a hidden field which points to the component instances which point to .. DOM nodes, I guess. now accepts a argument for a better warning which pulls component instances into the which in turn pull nodes which in turn pull components.", "positive_passages": [{"docid": "doc-en-react-4b3c73ac4468322793d0e1ecf7e2a781a1c66a161b84017d2e876f2ae15d9837", "text": "} } <ins> function stripComplexValues(key, value) { if (typeof value !== 'object' || Array.isArray(value) || value == null) { return value; } var prototype = Object.getPrototypeOf(value); if (!prototype || prototype === Object.prototype) { return value; } return '<not serializable>'; } </ins> // This implementation of ReactPerf is going away some time mid 15.x. // While we plan to keep most of the API, the actual format of measurements // will change dramatically. To signal this, we wrap them into an opaque-ish", "commid": "react_pr_6289"}], "negative_passages": []}
{"query_id": "q-en-react-3d98ae18f9257a516b9db4fe9f78cf6bbef3f1800e1fd3c1d3d3398c954d179e", "query": "Identical app. I call after the app is loaded. React 0.14.7: <img width=\"622\" alt=\"screen shot 2016-03-17 at 20 31 56\" src=\"\"React 15.0 RC1, RC2 and master: <img width=\"635\" alt=\"screen shot 2016-03-17 at 20 34 02\" src=\"\"We should fix this before releasing 15.0.\nThere seem to be two distinct things causing this issue: is now a possible argument for and points to DOM nodes which now have a hidden field which points to the component instances which point to .. DOM nodes, I guess. now accepts a argument for a better warning which pulls component instances into the which in turn pull nodes which in turn pull components.", "positive_passages": [{"docid": "doc-en-react-d8f2dda34574601eeeec89406569e226a683753e3c6e8fd942bbf447d0626c3e", "text": "var result = {}; result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id; result.type = item.type; <del> result.args = JSON.stringify(item.args); </del> <ins> result.args = JSON.stringify(item.args, stripComplexValues); </ins> return result; })); console.log(", "commid": "react_pr_6289"}], "negative_passages": []}
{"query_id": "q-en-react-3d98ae18f9257a516b9db4fe9f78cf6bbef3f1800e1fd3c1d3d3398c954d179e", "query": "Identical app. I call after the app is loaded. React 0.14.7: <img width=\"622\" alt=\"screen shot 2016-03-17 at 20 31 56\" src=\"\"React 15.0 RC1, RC2 and master: <img width=\"635\" alt=\"screen shot 2016-03-17 at 20 34 02\" src=\"\"We should fix this before releasing 15.0.\nThere seem to be two distinct things causing this issue: is now a possible argument for and points to DOM nodes which now have a hidden field which points to the component instances which point to .. DOM nodes, I guess. now accepts a argument for a better warning which pulls component instances into the which in turn pull nodes which in turn pull components.", "positive_passages": [{"docid": "doc-en-react-fcd031005964af0e55daa779aa69e2d2f0aa39a745ba6634200fce566347a552", "text": "expect(summary).toEqual([]); }); <ins> it('should print a table after calling printOperations', function() { var container = document.createElement('div'); var measurements = measure(() => { ReactDOM.render(<Div>hey</Div>, container); }); spyOn(console, 'table'); ReactDefaultPerf.printOperations(measurements); expect(console.table.calls.length).toBe(1); expect(console.table.argsForCall[0][0]).toEqual([{ 'data-reactid': '', type: 'set innerHTML', args: '{\"node\":\"<not serializable>\",\"children\":[],\"html\":null,\"text\":null}', }]); }); </ins> it('warns once when using getMeasurementsSummaryMap', function() { var measurements = measure(() => {}); spyOn(console, 'error');", "commid": "react_pr_6289"}], "negative_passages": []}
{"query_id": "q-en-react-bf40d349cb3bac46d4f001bd6fcbb73da8b38fb6656956f6faa2afad9a275397", "query": "To reproduce, open Error is logged to browser dev tools (in Chrome & Firefox, somehow not in Safari). Happens on v15.0.0-rc.2 and on latest master version. The assignment of additional event data to the newly created SyntheticEvent triggers a console error:\nThanks for reporting. We'll get this fixed.\nAre we not checking for unexpected warnings in tests? Should we? Curious how this crept in unnoticed.\nnode doesn't support Proxies so none of that code is actually getting tested :/ Even running with flag (which we do at least with ) doesn't enable it since it's \"in progress\". We could probably run with to force it on.", "positive_passages": [{"docid": "doc-en-react-19a55b5d1e2e38eba4e2a1b64ee68e0e3babc09e5a5276c08790e8edc8a0b433", "text": "); }); <del> it('should properly log warnings when events simulated with rendered components', function() { </del> <ins> // TODO: reenable this test. We are currently silencing these warnings when // using TestUtils.Simulate to avoid spurious warnings that result from the // way we simulate events. xit('should properly log warnings when events simulated with rendered components', function() { </ins> spyOn(console, 'error'); var event; var element = document.createElement('div');", "commid": "react_pr_6380"}], "negative_passages": []}
{"query_id": "q-en-react-bf40d349cb3bac46d4f001bd6fcbb73da8b38fb6656956f6faa2afad9a275397", "query": "To reproduce, open Error is logged to browser dev tools (in Chrome & Firefox, somehow not in Safari). Happens on v15.0.0-rc.2 and on latest master version. The assignment of additional event data to the newly created SyntheticEvent triggers a console error:\nThanks for reporting. We'll get this fixed.\nAre we not checking for unexpected warnings in tests? Should we? Curious how this crept in unnoticed.\nnode doesn't support Proxies so none of that code is actually getting tested :/ Even running with flag (which we do at least with ) doesn't enable it since it's \"in progress\". We could probably run with to force it on.", "positive_passages": [{"docid": "doc-en-react-07c6e03cfc670a2f9254bdc3abbf8762aa84a413a6d8ba1438682e58fc2a6dca", "text": "fakeNativeEvent, node ); <ins> // Since we aren't using pooling, always persist the event. This will make // sure it's marked and won't warn when setting additional properties. event.persist(); </ins> Object.assign(event, eventData); if (dispatchConfig.phasedRegistrationNames) {", "commid": "react_pr_6380"}], "negative_passages": []}
{"query_id": "q-en-react-bf40d349cb3bac46d4f001bd6fcbb73da8b38fb6656956f6faa2afad9a275397", "query": "To reproduce, open Error is logged to browser dev tools (in Chrome & Firefox, somehow not in Safari). Happens on v15.0.0-rc.2 and on latest master version. The assignment of additional event data to the newly created SyntheticEvent triggers a console error:\nThanks for reporting. We'll get this fixed.\nAre we not checking for unexpected warnings in tests? Should we? Curious how this crept in unnoticed.\nnode doesn't support Proxies so none of that code is actually getting tested :/ Even running with flag (which we do at least with ) doesn't enable it since it's \"in progress\". We could probably run with to force it on.", "positive_passages": [{"docid": "doc-en-react-53449e4b871275de3f9da580466427072f2955c5078a0a1c5e4e5546f03b54be", "text": "expect(handler).not.toHaveBeenCalled(); }); <ins> it('should not warn when simulating events with extra properties', function() { spyOn(console, 'error'); var CLIENT_X = 100; var Component = React.createClass({ handleClick: function(e) { expect(e.clientX).toBe(CLIENT_X); }, render: function() { return <div onClick={this.handleClick} />; }, }); var element = document.createElement('div'); var instance = ReactDOM.render(<Component />, element); ReactTestUtils.Simulate.click( ReactDOM.findDOMNode(instance), {clientX: CLIENT_X} ); expect(console.error.calls.length).toBe(0); }); </ins> it('can scry with stateless components involved', function() { var Stateless = () => <div><hr /></div>; var SomeComponent = React.createClass({", "commid": "react_pr_6380"}], "negative_passages": []}
{"query_id": "q-en-react-1726598a94edc3c2f874889fcbe58faf34610b1d7dd3b6cefc52cd7251ff49c1", "query": "has two calls to the Component class construction which are missing use of the 'new' operator. The calls are like this: Component(publicProps, publicContext, updateQueue) and are here: and here:\nThis is intentional. We check if we need to construct , and then use it to either call or not. This lets us support functional components and factory components:", "positive_passages": [{"docid": "doc-en-react-bae16eec0dd3565842ce436106ef68828fe80fc84476082d1fd119fcb4e0acbc", "text": "var args = [ \"bin/jsx\", <ins> \"--cache-dir\", \".module-cache\", </ins> config.sourceDir, config.outputDir ];", "commid": "react_pr_72"}], "negative_passages": []}
{"query_id": "q-en-react-dedf4fd2183c619deccd280e1061ebe42854a38ff79bb4a0837386e24f1b5a9a", "query": "Do you want to request a feature or report a bug? This is more of a documentation discussion What is the current behavior? Currently, the contributing guide lists the lint step before running prettier. For example, says: If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via or similar (template: ). What is the expected behavior? I think it would make more sense to run prettier first, since it can automatically get rid of certain lint errors (like single-quotes or comma-dangle). A first-time contributor following the steps in order might waste time fixing things manually at the lint step before proceeding to the formatting step. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? N/A\nHappy to take PR fixing it.\nThanks to reminding, I make a PR for it.\nSeems like this was fixed.", "positive_passages": [{"docid": "doc-en-react-015709363245c9604cb6df90cb9e3bacb19c5f235e4ef638ae9f6d33eeefc145", "text": "2. If you've added code that should be tested, add tests! 3. If you've changed APIs, update the documentation. 4. Ensure the test suite passes (`npm test`). <del> 5. Make sure your code lints (`npm run lint`). 6. Format your code with [prettier](https://github.com/prettier/prettier) (`npm run prettier`). </del> <ins> 5. Format your code with [prettier](https://github.com/prettier/prettier) (`npm run prettier`). 6. Make sure your code lints (`npm run lint`). </ins> 7. Run the [Flow](https://flowtype.org/) typechecks (`npm run flow`). 8. If you added or removed any tests, run `./scripts/fiber/record-tests` before submitting the pull request, and commit the resulting changes. 9. If you haven't already, complete the CLA.", "commid": "react_pr_10094"}], "negative_passages": []}
{"query_id": "q-en-react-32a7059d8beab748b4069c493b1b924912890d7a4bafbb343ae7c740995d25f2", "query": "We don't use rAF for scheduling anything anymore, yet we still enable it in ReactDOMFrameScheduling. It can probably be simplified a bit by not exposing it.", "positive_passages": [{"docid": "doc-en-react-8b6ecb04811a9c7d02e42d3b7da07fad0ace853399c921c809a454a8a2bad3a9", "text": "var invariant = require('fbjs/lib/invariant'); var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment'); <del> // TODO: There's no way to cancel these, because Fiber doesn't atm. let rAF: (callback: (time: number) => void) => number; </del> <ins> // TODO: There's no way to cancel, because Fiber doesn't atm. </ins> let rIC: (callback: (deadline: Deadline) => void) => number; if (!ExecutionEnvironment.canUseDOM) { <del> rAF = function(frameCallback: (time: number) => void): number { setTimeout(frameCallback, 16); return 0; }; </del> rIC = function(frameCallback: (deadline: Deadline) => void): number { setTimeout(() => { frameCallback({", "commid": "react_pr_10337"}], "negative_passages": []}
{"query_id": "q-en-react-32a7059d8beab748b4069c493b1b924912890d7a4bafbb343ae7c740995d25f2", "query": "We don't use rAF for scheduling anything anymore, yet we still enable it in ReactDOMFrameScheduling. It can probably be simplified a bit by not exposing it.", "positive_passages": [{"docid": "doc-en-react-20dc3a0550a2b64bd4f76ecefeb53082a0f67bb0e79984bd6a193b70a590cf0d", "text": "'polyfill in older browsers.', ); } else if (typeof requestIdleCallback !== 'function') { <del> // Wrap requestAnimationFrame and polyfill requestIdleCallback. </del> <ins> // Polyfill requestIdleCallback. </ins> var scheduledRAFCallback = null; var scheduledRICCallback = null;", "commid": "react_pr_10337"}], "negative_passages": []}
{"query_id": "q-en-react-32a7059d8beab748b4069c493b1b924912890d7a4bafbb343ae7c740995d25f2", "query": "We don't use rAF for scheduling anything anymore, yet we still enable it in ReactDOMFrameScheduling. It can probably be simplified a bit by not exposing it.", "positive_passages": [{"docid": "doc-en-react-46379f96675d33badbd23c4b834640a2259336e911ae323561f0671744a47cb9", "text": "isIdleScheduled = false; var callback = scheduledRICCallback; scheduledRICCallback = null; <del> if (callback) { </del> <ins> if (callback !== null) { </ins> callback(frameDeadlineObject); } };", "commid": "react_pr_10337"}], "negative_passages": []}
{"query_id": "q-en-react-32a7059d8beab748b4069c493b1b924912890d7a4bafbb343ae7c740995d25f2", "query": "We don't use rAF for scheduling anything anymore, yet we still enable it in ReactDOMFrameScheduling. It can probably be simplified a bit by not exposing it.", "positive_passages": [{"docid": "doc-en-react-73679dbb6bb881f78c0c2f106314c248a5651db91d377fc6dd7e202f640758d3", "text": "} var callback = scheduledRAFCallback; scheduledRAFCallback = null; <del> if (callback) { </del> <ins> if (callback !== null) { </ins> callback(rafTime); } }; <del> rAF = function(callback: (time: number) => void): number { // This assumes that we only schedule one callback at a time because that's // how Fiber uses it. scheduledRAFCallback = callback; if (!isAnimationFrameScheduled) { // If rIC didn't already schedule one, we need to schedule a frame. isAnimationFrameScheduled = true; requestAnimationFrame(animationTick); } return 0; }; </del> rIC = function(callback: (deadline: Deadline) => void): number { // This assumes that we only schedule one callback at a time because that's // how Fiber uses it.", "commid": "react_pr_10337"}], "negative_passages": []}
{"query_id": "q-en-react-32a7059d8beab748b4069c493b1b924912890d7a4bafbb343ae7c740995d25f2", "query": "We don't use rAF for scheduling anything anymore, yet we still enable it in ReactDOMFrameScheduling. It can probably be simplified a bit by not exposing it.", "positive_passages": [{"docid": "doc-en-react-d872a3e70fbb39378c2818af703116703dc2d785b89f93dd6dc2b16d6f0836ea", "text": "return 0; }; } else { <del> rAF = requestAnimationFrame; </del> rIC = requestIdleCallback; } <del> exports.rAF = rAF; </del> exports.rIC = rIC;", "commid": "react_pr_10337"}], "negative_passages": []}
{"query_id": "q-en-react-b85c2f634aeb025a447d3abfc3da8c2e6faeaecd8a47e2e1d570cf04625729f3", "query": "Do you want to request a feature or report a bug? bug What is the current behavior? In the render Fragments example, the JSX tag is closed prematurely. If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via or similar (template: ). \u2014 What is the expected behavior? Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React 16.0.0 documentation website on Chrome Android. Previously array Fragments weren't supported.", "positive_passages": [{"docid": "doc-en-react-2d1b8484c030396317a953d09cfab995f2fc2c5e685ad8ebcfa08cecc4a3b1db", "text": "```javascript render() { return [ <del> <li key=\"A\"/>First item</li>, <li key=\"B\"/>Second item</li>, <li key=\"C\"/>Third item</li>, </del> <ins> <li key=\"A\">First item</li>, <li key=\"B\">Second item</li>, <li key=\"C\">Third item</li>, </ins> ]; } ```", "commid": "react_pr_10885"}], "negative_passages": []}
{"query_id": "q-en-react-44070ddcc79a671b0d3a2ac9ea44e2784e43769830f718e08b1dd5ef06cf2537", "query": "The current default behavior is that keyboard users will get to the code sections of the live editor and get stuck. Can someone configure ignoreTabKey which makes the editor ignore tab key presses so that keyboard users can tab past the editor without getting stuck? Chrome on Windows atm and cannot edit it to submit a fix. Sorry about that :(\nThanks for bringing this to our attention", "positive_passages": [{"docid": "doc-en-react-331e6031c961e9da6f4709ef6a4e6c72a4975cd55ed2c1d86dc410d20eafe954", "text": "}, }} className=\"gatsby-highlight\"> <del> <LiveEditor onChange={this._onChange} /> </del> <ins> <LiveEditor onChange={this._onChange} ignoreTabKey={true} /> </ins> </div> </div> {error &&", "commid": "react_pr_10992"}], "negative_passages": []}
{"query_id": "q-en-react-abb3470d8306964cd5c09e50d6c4767d91e0739ecf0a7525b15a80749def46f0", "query": "Do you want to request a feature or report a bug? Improvement What is the current behavior? does not currently support the property. () is nice to have when you want to write key-specific handling\u2014rather than input-specific (dependent on layout and modifier keys) handling. What is the expected behavior? already exposes a property. It should have a property as well. Currently, if you want to use the 's , you must access it through 's . Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? Affects React 16 and earlier (I assume).\nI created the PR for this.\nthe above PR is stale and closed; should I pick this up? planning to replicate the same and follow the PR suggestions; any tips or idea?\nCan you give me an idea of how widely supported it is?\nAccording to it is supported in all major desktop browsers. Are there any plans to implement this? I am not sure whether I should mark it with until this issue is resolved or don't use it at all.\nThis issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!", "positive_passages": [{"docid": "doc-en-react-9319f132e6525d6239aa66ad0880f7f380fa4e0b62bdaa38f78684b548071870", "text": "function getUnboundedScrollPosition(scrollable) { if (scrollable === window) { return { <del> x: document.documentElement.scrollLeft || document.body.scrollLeft, y: document.documentElement.scrollTop || document.body.scrollTop </del> <ins> x: window.pageXOffset || document.documentElement.scrollLeft, y: window.pageYOffset || document.documentElement.scrollTop </ins> }; } return {", "commid": "react_pr_643"}], "negative_passages": []}
{"query_id": "q-en-react-11ac5bb9256388708266007fff66256fb5f39b0331720f085eb132493871f883", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? bug What is the current behavior? <!-- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: --The change seems to have broken the server-side rendering on : I'm attempting to the to test and getting the following error from the server-side when I load the page: It points to this line: What is the expected behavior? No ReferenceError in server-side environment. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? (not published at the time of writing) Node environment: during server-side rendering in response to a browser request.\nfixed in", "positive_passages": [{"docid": "doc-en-react-dd64779ffc2e6710d1f20828d8b16a216834598616ed745fd862718e398ca056", "text": "import requestAnimationFrameForReact from 'shared/requestAnimationFrameForReact'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; <ins> import invariant from 'fbjs/lib/invariant'; import warning from 'fbjs/lib/warning'; </ins> // We capture a local reference to any global, in case it gets polyfilled after // this module is initially evaluated.", "commid": "react_pr_13001"}], "negative_passages": []}
{"query_id": "q-en-react-11ac5bb9256388708266007fff66256fb5f39b0331720f085eb132493871f883", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? bug What is the current behavior? <!-- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: --The change seems to have broken the server-side rendering on : I'm attempting to the to test and getting the following error from the server-side when I load the page: It points to this line: What is the expected behavior? No ReferenceError in server-side environment. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? (not published at the time of writing) Node environment: during server-side rendering in response to a browser request.\nfixed in", "positive_passages": [{"docid": "doc-en-react-57edb4c375d56e410c84d78ab1abf994bd49bada84fd90f2d92439071cd3ffce", "text": "localClearTimeout(timeoutId); }; } else { <ins> if (__DEV__) { if (typeof requestAnimationFrameForReact !== 'function') { warning( false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills', ); } } let localRequestAnimationFrame = typeof requestAnimationFrameForReact === 'function' ? requestAnimationFrameForReact : function(callback: Function) { invariant( false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills', ); }; </ins> let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null; let tailOfPendingCallbacksLinkedList: CallbackConfigType | null = null;", "commid": "react_pr_13001"}], "negative_passages": []}
{"query_id": "q-en-react-11ac5bb9256388708266007fff66256fb5f39b0331720f085eb132493871f883", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? bug What is the current behavior? <!-- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: --The change seems to have broken the server-side rendering on : I'm attempting to the to test and getting the following error from the server-side when I load the page: It points to this line: What is the expected behavior? No ReferenceError in server-side environment. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? (not published at the time of writing) Node environment: during server-side rendering in response to a browser request.\nfixed in", "positive_passages": [{"docid": "doc-en-react-03f13bfe2ae5f363cb53df0c8c01d9b6292825066268131173d65a079998dc01", "text": "if (!isAnimationFrameScheduled) { // Schedule another animation callback so we retry later. isAnimationFrameScheduled = true; <del> requestAnimationFrameForReact(animationTick); </del> <ins> localRequestAnimationFrame(animationTick); </ins> } } };", "commid": "react_pr_13001"}], "negative_passages": []}
{"query_id": "q-en-react-11ac5bb9256388708266007fff66256fb5f39b0331720f085eb132493871f883", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? bug What is the current behavior? <!-- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: --The change seems to have broken the server-side rendering on : I'm attempting to the to test and getting the following error from the server-side when I load the page: It points to this line: What is the expected behavior? No ReferenceError in server-side environment. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? (not published at the time of writing) Node environment: during server-side rendering in response to a browser request.\nfixed in", "positive_passages": [{"docid": "doc-en-react-e49b1c1bc8dea91cbf69bba70b25c4e5cf4db8c7e86c7e0eba6192116f5d3afe", "text": "// might want to still have setTimeout trigger scheduleWork as a backup to ensure // that we keep performing work. isAnimationFrameScheduled = true; <del> requestAnimationFrameForReact(animationTick); </del> <ins> localRequestAnimationFrame(animationTick); </ins> } return scheduledCallbackConfig; };", "commid": "react_pr_13001"}], "negative_passages": []}
{"query_id": "q-en-react-11ac5bb9256388708266007fff66256fb5f39b0331720f085eb132493871f883", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? bug What is the current behavior? <!-- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: --The change seems to have broken the server-side rendering on : I'm attempting to the to test and getting the following error from the server-side when I load the page: It points to this line: What is the expected behavior? No ReferenceError in server-side environment. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? (not published at the time of writing) Node environment: during server-side rendering in response to a browser request.\nfixed in", "positive_passages": [{"docid": "doc-en-react-47040be27fdc604483bb31995a2e1e4197aaab464b08eeadeff13d2f4e46d24e", "text": "'use strict'; <del> import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; import warning from 'fbjs/lib/warning'; </del> // We capture a local reference to any global, in case it gets polyfilled after // this module is initially evaluated. // We want to be using a consistent implementation. <del> const localRequestAnimationFrame = requestAnimationFrame; </del> <ins> const localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined; </ins> <del> if (__DEV__) { if ( ExecutionEnvironment.canUseDOM && typeof localRequestAnimationFrame !== 'function' ) { warning( false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills', ); } } </del> <ins> // The callsites should check if the requestAnimationFrame imported from this module is a function, // fire a developer warning if it doesn't exist, and substitute it by a shim in that case // (e.g. that throws on call). </ins> export default localRequestAnimationFrame;", "commid": "react_pr_13001"}], "negative_passages": []}
{"query_id": "q-en-react-c66a824583a554f568311edf1035760970897b46712b094dc80d82247e05391d", "query": "Do you want to request a feature or report a bug? Bug (for electron users) What is the current behavior? When running jest, if any components containing a webview element are rendered, a warning is rendered to the console. When many tests are run, the output is littered with warnings. If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle () or CodeSandbox () example below: What is the expected behavior? No warning is logged to the console. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React: 16.4.1 Electron: 2.0.6 Unknown if it worked in prior versions of react.\nWhat other special tags does Electron have?\nLooking through their docs it seems to be only the tag for now:\nIn that case I don\u2019t mind adding it to the whitelist. Send a PR?\nYou beat me to the punch. Thanks so much and", "positive_passages": [{"docid": "doc-en-react-9f45e47d3b12e399ea5af79a585918b90e91df05a51278cc8643a8227b17c03b", "text": "time: true, // There are working polyfills for <dialog>. Let people use it. dialog: true, <ins> // Electron ships a custom <webview> tag to display external web content in // an isolated frame and process. // This tag is not present in non Electron environments such as JSDom which // is often used for testing purposes. // @see https://electronjs.org/docs/api/webview-tag webview: true, </ins> }; validatePropertiesInDevelopment = function(type, props) {", "commid": "react_pr_13301"}], "negative_passages": []}
{"query_id": "q-en-react-f7f1e4aacced6b4ced7f94f1b45abe079f32710c0563e78419e22c935d59a557", "query": "With this: If I render again after it resolves, it won't get the default prop value. This is a bug.", "positive_passages": [{"docid": "doc-en-react-56139598b4c8f3e884ae6b0c37a5494bc9f4d21e841afc8e704fb7943d54be89", "text": "): null | Fiber { if (current === null) { let type = Component.type; <del> if (isSimpleFunctionComponent(type) && Component.compare === null) { </del> <ins> if ( isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. Component.defaultProps === undefined ) { </ins> // If this is a plain function component without default props, // and with only the default shallow comparison, we upgrade it // to a SimpleMemoComponent to allow fast path updates.", "commid": "react_pr_14312"}], "negative_passages": []}
{"query_id": "q-en-react-f7f1e4aacced6b4ced7f94f1b45abe079f32710c0563e78419e22c935d59a557", "query": "With this: If I render again after it resolves, it won't get the default prop value. This is a bug.", "positive_passages": [{"docid": "doc-en-react-a901a94e41cca650d20f1157069870b1c9719db2b22a508289cef354ca286ff0", "text": "case MemoComponent: { const type = workInProgress.type; const unresolvedProps = workInProgress.pendingProps; <del> const resolvedProps = resolveDefaultProps(type.type, unresolvedProps); </del> <ins> // Resolve outer props first, then resolve inner props. let resolvedProps = resolveDefaultProps(type, unresolvedProps); resolvedProps = resolveDefaultProps(type.type, resolvedProps); </ins> return updateMemoComponent( current, workInProgress,", "commid": "react_pr_14312"}], "negative_passages": []}
{"query_id": "q-en-react-f7f1e4aacced6b4ced7f94f1b45abe079f32710c0563e78419e22c935d59a557", "query": "With this: If I render again after it resolves, it won't get the default prop value. This is a bug.", "positive_passages": [{"docid": "doc-en-react-c79cc1ae7c1206ff8dbd3572a449cc7b4a58bf23bd3f845b4981ba60479f19e8", "text": "expect(root).toMatchRenderedOutput('FooBar'); expect(ref.current).not.toBe(null); }); <ins> // Regression test for #14310 it('supports defaultProps defined on the memo() return value', async () => { const Add = React.memo(props => { return props.inner + props.outer; }); Add.defaultProps = { inner: 2, }; const LazyAdd = lazy(() => fakeImport(Add)); const root = ReactTestRenderer.create( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={2} /> </Suspense>, { unstable_isConcurrent: true, }, ); expect(root).toFlushAndYield(['Loading...']); expect(root).toMatchRenderedOutput(null); // Mount await Promise.resolve(); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('4'); // Update (shallowly equal) root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={2} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('4'); // Update root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={3} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('5'); // Update (shallowly equal) root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={3} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('5'); // Update (explicit props) root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={1} inner={1} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('2'); // Update (explicit props, shallowly equal) root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={1} inner={1} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('2'); // Update root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={1} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('3'); }); it('merges defaultProps in the correct order', async () => { let Add = React.memo(props => { return props.inner + props.outer; }); Add.defaultProps = { inner: 100, }; Add = React.memo(Add); Add.defaultProps = { inner: 2, outer: 0, }; const LazyAdd = lazy(() => fakeImport(Add)); const root = ReactTestRenderer.create( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={2} /> </Suspense>, { unstable_isConcurrent: true, }, ); expect(root).toFlushAndYield(['Loading...']); expect(root).toMatchRenderedOutput(null); // Mount await Promise.resolve(); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('4'); // Update root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd outer={3} /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('5'); // Update root.update( <Suspense fallback={<Text text=\"Loading...\" />}> <LazyAdd /> </Suspense>, ); root.unstable_flushAll(); expect(root).toMatchRenderedOutput('2'); }); </ins> });", "commid": "react_pr_14312"}], "negative_passages": []}
{"query_id": "q-en-react-3257d0bd661a5daf53c5157229a9318583e36e01783e23463c66fd0035d03afc", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? Bug What is the current behavior? when typing in a controlled input, the cursor always jumps to the end. This was an old issue that seems to have resurfaced. used in the docs has the problem in all browsers as far as I have been able to test. What is the expected behavior? because we are using the state to update the component as soon as it's changed, the input element should be able to keep the cursor in the same place. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I'm at latest (16.8.2) and I tested on Chrome, FireFox, and Edge on Windows as far as I know, this was working at some point, though I don't know how long ago. possibly even before \"Fiber\"\nThis is quite weird. Same code works for me on CodeSandbox: Not sure what's going on here.\nSeems UMD-specific.\nThank you very much for reporting this. It's a serious regression in the last patch release, and exposed some lacking coverage in our test suite regarding UMD bundles. I have a fix ready in\nGreat! thank you for the fix.\nThis is fixed in 16.8.3. Unfortunately unpkg doesn't seem to pick up the 16.8.3 version yet from its default redirect.\nThat's OK, I replaced the resources with the specific release artifacts to test and it works great now.\nit flipped for me and I'm actually having the same problem OP reported in your CodeSandbox, but not in his codepen. Should that be? Chrome 74\nI've updated from react 16.8.1 to 16.8.6. Still having the same problem...\nI am running into this same issue. I have created the following fiddle which is a boiled down version of what I have. Ultimately once the event stack finishes it appears that React clears the value in the input since it is controlled. Then when the timeout fires it sets the correct value but at this time the position is lost. I tried the fix this by handling the state internally to the TestInput Component as in the following fiddle. But after debugging it appears that setState causes getDerivedStateFromProps to be called which has the old value and I end up in the same mess. I feel I need getDerivedStateFromProps because I have handle the case where the value can change externally and I need to set the state to this new value. I believe if getDerivedStateFromProps was NOT called for a setState change then perhaps this problem would not exist, at least for my second example. But I am not familiar with the internals of React to even feel confident in this suggestion, so please take it with a grain of salt of course.\nOkay based on my second fiddle I have come up with the following solution which should not require weird cursor manipulation. Please review, test, and use at your discretion. I have tested it a little and it appears to work. If I run into any problems I will post here.\nIs this issue fixed? I'm having the same problem in 16.8.6.\nHere is how I reproduce this issue. Is there something I'm doing wrong (or should do differently)?\nThere are 2 possible ways to get around this issue, as far as I can tell. Solution 1: Use the from the prop. Solution 2: Update the local state simultaneously as the parent state.\nYou're round-tripping the value change from to and back to and then calling . Apparently this round-trip makes React forget/reset the cursor position because I assume it looses a association between value and input element and/or re-renders the whole component. suggested in to call directly in the component which does work, but is not ideal when one prefers a stateless component. What I've done to workaround is to make the uncontrolled (change to ) with a prop. This also brings the benefit of the input remaining responsive when is computationally expensive.\nIn your example if you make a change, the InputChild component will be rendered once with outdated values. This is because the new value isn't set until useEffect. So whatever you typed will be erased for one frame, then put back after useEffect. This is enough to make the cursor position ambiguous to the browser. As a hack suggestion, you can swap useEffect with useMemo. This works because useMemo runs before render.", "positive_passages": [{"docid": "doc-en-react-964a22c24c6992161f13ba2e6933ef22213786af06cffcb47fc386806ee0b7e2", "text": "unstable_continueExecution, unstable_wrapCallback, unstable_getCurrentPriorityLevel, <ins> unstable_IdlePriority, unstable_ImmediatePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, </ins> } from 'scheduler'; import { __interactionsRef,", "commid": "react_pr_14914"}], "negative_passages": []}
{"query_id": "q-en-react-3257d0bd661a5daf53c5157229a9318583e36e01783e23463c66fd0035d03afc", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? Bug What is the current behavior? when typing in a controlled input, the cursor always jumps to the end. This was an old issue that seems to have resurfaced. used in the docs has the problem in all browsers as far as I have been able to test. What is the expected behavior? because we are using the state to update the component as soon as it's changed, the input element should be able to keep the cursor in the same place. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I'm at latest (16.8.2) and I tested on Chrome, FireFox, and Edge on Windows as far as I know, this was working at some point, though I don't know how long ago. possibly even before \"Fiber\"\nThis is quite weird. Same code works for me on CodeSandbox: Not sure what's going on here.\nSeems UMD-specific.\nThank you very much for reporting this. It's a serious regression in the last patch release, and exposed some lacking coverage in our test suite regarding UMD bundles. I have a fix ready in\nGreat! thank you for the fix.\nThis is fixed in 16.8.3. Unfortunately unpkg doesn't seem to pick up the 16.8.3 version yet from its default redirect.\nThat's OK, I replaced the resources with the specific release artifacts to test and it works great now.\nit flipped for me and I'm actually having the same problem OP reported in your CodeSandbox, but not in his codepen. Should that be? Chrome 74\nI've updated from react 16.8.1 to 16.8.6. Still having the same problem...\nI am running into this same issue. I have created the following fiddle which is a boiled down version of what I have. Ultimately once the event stack finishes it appears that React clears the value in the input since it is controlled. Then when the timeout fires it sets the correct value but at this time the position is lost. I tried the fix this by handling the state internally to the TestInput Component as in the following fiddle. But after debugging it appears that setState causes getDerivedStateFromProps to be called which has the old value and I end up in the same mess. I feel I need getDerivedStateFromProps because I have handle the case where the value can change externally and I need to set the state to this new value. I believe if getDerivedStateFromProps was NOT called for a setState change then perhaps this problem would not exist, at least for my second example. But I am not familiar with the internals of React to even feel confident in this suggestion, so please take it with a grain of salt of course.\nOkay based on my second fiddle I have come up with the following solution which should not require weird cursor manipulation. Please review, test, and use at your discretion. I have tested it a little and it appears to work. If I run into any problems I will post here.\nIs this issue fixed? I'm having the same problem in 16.8.6.\nHere is how I reproduce this issue. Is there something I'm doing wrong (or should do differently)?\nThere are 2 possible ways to get around this issue, as far as I can tell. Solution 1: Use the from the prop. Solution 2: Update the local state simultaneously as the parent state.\nYou're round-tripping the value change from to and back to and then calling . Apparently this round-trip makes React forget/reset the cursor position because I assume it looses a association between value and input element and/or re-renders the whole component. suggested in to call directly in the component which does work, but is not ideal when one prefers a stateless component. What I've done to workaround is to make the uncontrolled (change to ) with a prop. This also brings the benefit of the input remaining responsive when is computationally expensive.\nIn your example if you make a change, the InputChild component will be rendered once with outdated values. This is because the new value isn't set until useEffect. So whatever you typed will be erased for one frame, then put back after useEffect. This is enough to make the cursor position ambiguous to the browser. As a hack suggestion, you can swap useEffect with useMemo. This works because useMemo runs before render.", "positive_passages": [{"docid": "doc-en-react-33adee56f9b4518fbadc20fe864e3084d7caa7c18a41a7a272b574bb38cba7c2", "text": "unstable_pauseExecution, unstable_continueExecution, unstable_getCurrentPriorityLevel, <ins> unstable_IdlePriority, unstable_ImmediatePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, </ins> }, SchedulerTracing: { __interactionsRef,", "commid": "react_pr_14914"}], "negative_passages": []}
{"query_id": "q-en-react-3257d0bd661a5daf53c5157229a9318583e36e01783e23463c66fd0035d03afc", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? Bug What is the current behavior? when typing in a controlled input, the cursor always jumps to the end. This was an old issue that seems to have resurfaced. used in the docs has the problem in all browsers as far as I have been able to test. What is the expected behavior? because we are using the state to update the component as soon as it's changed, the input element should be able to keep the cursor in the same place. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I'm at latest (16.8.2) and I tested on Chrome, FireFox, and Edge on Windows as far as I know, this was working at some point, though I don't know how long ago. possibly even before \"Fiber\"\nThis is quite weird. Same code works for me on CodeSandbox: Not sure what's going on here.\nSeems UMD-specific.\nThank you very much for reporting this. It's a serious regression in the last patch release, and exposed some lacking coverage in our test suite regarding UMD bundles. I have a fix ready in\nGreat! thank you for the fix.\nThis is fixed in 16.8.3. Unfortunately unpkg doesn't seem to pick up the 16.8.3 version yet from its default redirect.\nThat's OK, I replaced the resources with the specific release artifacts to test and it works great now.\nit flipped for me and I'm actually having the same problem OP reported in your CodeSandbox, but not in his codepen. Should that be? Chrome 74\nI've updated from react 16.8.1 to 16.8.6. Still having the same problem...\nI am running into this same issue. I have created the following fiddle which is a boiled down version of what I have. Ultimately once the event stack finishes it appears that React clears the value in the input since it is controlled. Then when the timeout fires it sets the correct value but at this time the position is lost. I tried the fix this by handling the state internally to the TestInput Component as in the following fiddle. But after debugging it appears that setState causes getDerivedStateFromProps to be called which has the old value and I end up in the same mess. I feel I need getDerivedStateFromProps because I have handle the case where the value can change externally and I need to set the state to this new value. I believe if getDerivedStateFromProps was NOT called for a setState change then perhaps this problem would not exist, at least for my second example. But I am not familiar with the internals of React to even feel confident in this suggestion, so please take it with a grain of salt of course.\nOkay based on my second fiddle I have come up with the following solution which should not require weird cursor manipulation. Please review, test, and use at your discretion. I have tested it a little and it appears to work. If I run into any problems I will post here.\nIs this issue fixed? I'm having the same problem in 16.8.6.\nHere is how I reproduce this issue. Is there something I'm doing wrong (or should do differently)?\nThere are 2 possible ways to get around this issue, as far as I can tell. Solution 1: Use the from the prop. Solution 2: Update the local state simultaneously as the parent state.\nYou're round-tripping the value change from to and back to and then calling . Apparently this round-trip makes React forget/reset the cursor position because I assume it looses a association between value and input element and/or re-renders the whole component. suggested in to call directly in the component which does work, but is not ideal when one prefers a stateless component. What I've done to workaround is to make the uncontrolled (change to ) with a prop. This also brings the benefit of the input remaining responsive when is computationally expensive.\nIn your example if you make a change, the InputChild component will be rendered once with outdated values. This is because the new value isn't set until useEffect. So whatever you typed will be erased for one frame, then put back after useEffect. This is enough to make the cursor position ambiguous to the browser. As a hack suggestion, you can swap useEffect with useMemo. This works because useMemo runs before render.", "positive_passages": [{"docid": "doc-en-react-26bf766dfc67c8b83b097e859e016a5af2d75a45d256347bf0178b77bf58cec6", "text": "unstable_continueExecution: unstable_continueExecution, unstable_pauseExecution: unstable_pauseExecution, unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, <ins> get unstable_IdlePriority() { return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED .Scheduler.unstable_IdlePriority; }, get unstable_ImmediatePriority() { return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED .Scheduler.unstable_ImmediatePriority; }, get unstable_LowPriority() { return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED .Scheduler.unstable_LowPriority; }, get unstable_NormalPriority() { return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED .Scheduler.unstable_NormalPriority; }, get unstable_UserBlockingPriority() { return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED .Scheduler.unstable_UserBlockingPriority; }, </ins> }); });", "commid": "react_pr_14914"}], "negative_passages": []}
{"query_id": "q-en-react-3257d0bd661a5daf53c5157229a9318583e36e01783e23463c66fd0035d03afc", "query": "<!-- Note: if the issue is about documentation or the website, please file it at: --Do you want to request a feature or report a bug? Bug What is the current behavior? when typing in a controlled input, the cursor always jumps to the end. This was an old issue that seems to have resurfaced. used in the docs has the problem in all browsers as far as I have been able to test. What is the expected behavior? because we are using the state to update the component as soon as it's changed, the input element should be able to keep the cursor in the same place. Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? I'm at latest (16.8.2) and I tested on Chrome, FireFox, and Edge on Windows as far as I know, this was working at some point, though I don't know how long ago. possibly even before \"Fiber\"\nThis is quite weird. Same code works for me on CodeSandbox: Not sure what's going on here.\nSeems UMD-specific.\nThank you very much for reporting this. It's a serious regression in the last patch release, and exposed some lacking coverage in our test suite regarding UMD bundles. I have a fix ready in\nGreat! thank you for the fix.\nThis is fixed in 16.8.3. Unfortunately unpkg doesn't seem to pick up the 16.8.3 version yet from its default redirect.\nThat's OK, I replaced the resources with the specific release artifacts to test and it works great now.\nit flipped for me and I'm actually having the same problem OP reported in your CodeSandbox, but not in his codepen. Should that be? Chrome 74\nI've updated from react 16.8.1 to 16.8.6. Still having the same problem...\nI am running into this same issue. I have created the following fiddle which is a boiled down version of what I have. Ultimately once the event stack finishes it appears that React clears the value in the input since it is controlled. Then when the timeout fires it sets the correct value but at this time the position is lost. I tried the fix this by handling the state internally to the TestInput Component as in the following fiddle. But after debugging it appears that setState causes getDerivedStateFromProps to be called which has the old value and I end up in the same mess. I feel I need getDerivedStateFromProps because I have handle the case where the value can change externally and I need to set the state to this new value. I believe if getDerivedStateFromProps was NOT called for a setState change then perhaps this problem would not exist, at least for my second example. But I am not familiar with the internals of React to even feel confident in this suggestion, so please take it with a grain of salt of course.\nOkay based on my second fiddle I have come up with the following solution which should not require weird cursor manipulation. Please review, test, and use at your discretion. I have tested it a little and it appears to work. If I run into any problems I will post here.\nIs this issue fixed? I'm having the same problem in 16.8.6.\nHere is how I reproduce this issue. Is there something I'm doing wrong (or should do differently)?\nThere are 2 possible ways to get around this issue, as far as I can tell. Solution 1: Use the from the prop. Solution 2: Update the local state simultaneously as the parent state.\nYou're round-tripping the value change from to and back to and then calling . Apparently this round-trip makes React forget/reset the cursor position because I assume it looses a association between value and input element and/or re-renders the whole component. suggested in to call directly in the component which does work, but is not ideal when one prefers a stateless component. What I've done to workaround is to make the uncontrolled (change to ) with a prop. This also brings the benefit of the input remaining responsive when is computationally expensive.\nIn your example if you make a change, the InputChild component will be rendered once with outdated values. This is because the new value isn't set until useEffect. So whatever you typed will be erased for one frame, then put back after useEffect. This is enough to make the cursor position ambiguous to the browser. As a hack suggestion, you can swap useEffect with useMemo. This works because useMemo runs before render.", "positive_passages": [{"docid": "doc-en-react-e087f09488e267afc1f165c6e770b25844eca02ecbc846dc9c3875aa0303f41d", "text": "}); function filterPrivateKeys(name) { <del> // TODO: Figure out how to forward priority levels. return !name.startsWith('_') && !name.endsWith('Priority'); </del> <ins> // Be very careful adding things to this whitelist! // It's easy to introduce bugs by doing it: // https://github.com/facebook/react/issues/14904 switch (name) { case '__interactionsRef': case '__subscriberRef': // Don't forward these. (TODO: why?) return false; default: return true; } </ins> } function validateForwardedAPIs(api, forwardedAPIs) {", "commid": "react_pr_14914"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-22acbfca376d45951d077b8bca8aca29d5799c3b5103585b39d7c82a49f5e44a", "text": "<ins> /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const {useState} = require('react'); const {useCustom} = require('./useCustom'); function Component(props) { const [count] = useState(0); useCustom(); return count; } module.exports = {Component}; </ins> No newline at end of file", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-347b742e7434e0bea8f90700a6e4b1ec0c2862d062ff6c5a7bec1ccbef39b05e", "text": "<ins> /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const {useEffect} = require('react'); function useCustom() { useEffect(() => { // ... }, []); } module.exports = {useCustom}; </ins> No newline at end of file", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-0efc83d5db852e20f944c7b4130ab06caafe732f65b63559604794cc535c958c", "text": "expectHookNamesToEqual(hookNames, ['foo', 'bar', 'baz']); }); <del> it('should return null for hooks without names like useEffect', async () => { </del> <ins> it('should skip loading source files for unnamed hooks like useEffect', async () => { </ins> const Component = require('./__source__/__untransformed__/ComponentWithUseEffect') .Component; <ins> // Since this component contains only unnamed hooks, the source code should not even be loaded. fetchMock.mockIf(/.+$/, request => { throw Error(`Unexpected file request for \"${request.url}\"`); }); </ins> const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, []); // No hooks with names }); <ins> it('should skip loading source files for unnamed hooks like useEffect (alternate)', async () => { const Component = require('./__source__/__untransformed__/ComponentWithExternalUseEffect') .Component; fetchMock.mockIf(/.+$/, request => { // Since th custom hook contains only unnamed hooks, the source code should not be loaded. if (request.url.endsWith('useCustom.js')) { throw Error(`Unexpected file request for \"${request.url}\"`); } return Promise.resolve(requireText(request.url, 'utf8')); }); const hookNames = await getHookNamesForComponent(Component); expectHookNamesToEqual(hookNames, ['count', null]); // No hooks with names }); </ins> it('should parse names for custom hooks', async () => { const Component = require('./__source__/__untransformed__/ComponentWithNamedCustomHooks') .Component;", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-10e9b6e6559796909064d737fecee77c20a8340bb58c05cc201e078d6dbe893c", "text": "await test( './__source__/__compiled__/external/ComponentWithMultipleHooksPerLine', ); // external source map <del> await test( './__source__/__compiled__/bundle', 'ComponentWithMultipleHooksPerLine', ); // bundle source map </del> <ins> // await test( // './__source__/__compiled__/bundle', // 'ComponentWithMultipleHooksPerLine', // ); // bundle source map </ins> }); // TODO Inline require (e.g. require(\"react\").useState()) isn't supported yet.", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-254b983186fc6fc6fbc0cb1fa4e8c6edf8a6fcc79e96f60838f10ce3101d644c", "text": "return /^use[A-Z0-9].*$/.test(name); } <del> // Determines whether incoming hook is a primitive hook that gets assigned to variables. export function isNonDeclarativePrimitiveHook(hook: HooksNode) { return ['Effect', 'ImperativeHandle', 'LayoutEffect', 'DebugValue'].includes( hook.name, ); } </del> // Check if the AST Node COULD be a React Hook function isPotentialHookDeclaration(path: NodePath): boolean { // The array potentialHooksFound will contain all potential hook declaration cases we support", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-75fe5c375a14174197741dd6e08a8c5ef7fac6dea06070a57022dce3aea41d39", "text": "import {enableHookNameParsing} from 'react-devtools-feature-flags'; import LRU from 'lru-cache'; import {SourceMapConsumer} from 'source-map'; <del> import {getHookName, isNonDeclarativePrimitiveHook} from './astUtils'; </del> <ins> import {getHookName} from './astUtils'; </ins> import {areSourceMapsAppliedToErrors} from './ErrorTester'; import {__DEBUG__} from 'react-devtools-shared/src/constants'; import {getHookSourceLocationKey} from 'react-devtools-shared/src/hookNamesCache';", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-75a4bd4c51e5696d5436306cd88af5eff5885a14bc3be544a00788a3b65fbdaf", "text": "const map: HookNames = new Map(); hooksList.map(hook => { <del> // TODO (named hooks) We should probably filter before this point, // otherwise we are loading and parsing source maps and ASTs for nothing. if (isNonDeclarativePrimitiveHook(hook)) { if (__DEBUG__) { console.log('findHookNames() Non declarative primitive hook'); } // Not all hooks have names (e.g. useEffect or useLayoutEffect) return null; } </del> // We already guard against a null HookSource in parseHookNames() const hookSource = ((hook.hookSource: any): HookSource); const fileName = hookSource.fileName;", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-1976cdbeec1ba5a63b4910f922e5fe3f33ae39f7da35f6bbe91f34980cb0542d", "text": "): void { for (let i = 0; i < hooksTree.length; i++) { const hook = hooksTree[i]; <ins> if (isUnnamedBuiltInHook(hook)) { // No need to load source code or do any parsing for unnamed hooks. if (__DEBUG__) { console.log('flattenHooksList() Skipping unnamed hook', hook); } continue; } </ins> hooksList.push(hook); if (hook.subHooks.length > 0) { flattenHooksList(hook.subHooks, hooksList);", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-0da1cc93e83446efe19dc201ccd42e8444d2e91f995f8690ac35570e21fdb0b2", "query": "Hooks like or will never have names, so if a the only hooks for a given source file are these \"unnamed\" built-in hooks, we should skip loading the source code.", "positive_passages": [{"docid": "doc-en-react-83cacb43796886e29f5e6970e8f1b854644ac9a79d2953a0e47aa5c0f56602f1", "text": "} } <ins> // Determines whether incoming hook is a primitive hook that gets assigned to variables. function isUnnamedBuiltInHook(hook: HooksNode) { return ['Effect', 'ImperativeHandle', 'LayoutEffect', 'DebugValue'].includes( hook.name, ); } </ins> function updateLruCache( locationKeyToHookSourceData: Map<string, HookSourceData>, ): Promise<*> {", "commid": "react_pr_21835"}], "negative_passages": []}
{"query_id": "q-en-react-920fef893a94a75d7ab860855565a3ba08a6269c1ccfa2b0b833352987401c3f", "query": "Run the Next app, open up react dev tools and inspect the Box component, rendered by Every time react-devtools-extensions 23.0- Could not find ID for Fiber \"App\"\nHey, thanks for reporting this issue, and sorry it's blocking your workflow. Edit: The reason for this issue seems to be that there are multiple instances, and the one that we are using to get the fiber's ID when we inspect doesn't have the App fiber (a recursive owner of Box). We'll look into why this is occurring soon!\nFixed via", "positive_passages": [{"docid": "doc-en-react-822edf429a9785ef6d2dedd0908ee78b4e403f4dad0544ea9242e8e3424a99a3", "text": "}); }); <ins> it('inspecting nested renderers should not throw', async () => { // Ignoring react art warnings spyOn(console, 'error'); const ReactArt = require('react-art'); const ArtSVGMode = require('art/modes/svg'); const ARTCurrentMode = require('art/modes/current'); store.componentFilters = []; ARTCurrentMode.setCurrent(ArtSVGMode); const {Surface, Group} = ReactArt; function Child() { return ( <Surface width={1} height={1}> <Group /> </Surface> ); } function App() { return <Child />; } await utils.actAsync(() => { legacyRender(<App />, document.createElement('div')); }); expect(store).toMatchInlineSnapshot(` [root] \u25be <App> \u25be <Child> \u25be <Surface> <svg> [root] <Group> `); const inspectedElement = await inspectElementAtIndex(4); expect(inspectedElement.owners).toMatchInlineSnapshot(` Array [ Object { \"displayName\": \"Child\", \"hocDisplayNames\": null, \"id\": 3, \"key\": null, \"type\": 5, }, Object { \"displayName\": \"App\", \"hocDisplayNames\": null, \"id\": 2, \"key\": null, \"type\": 5, }, ] `); }); </ins> describe('error boundary', () => { it('can toggle error', async () => { class LocalErrorBoundary extends React.Component<any> {", "commid": "react_pr_24116"}], "negative_passages": []}
{"query_id": "q-en-react-920fef893a94a75d7ab860855565a3ba08a6269c1ccfa2b0b833352987401c3f", "query": "Run the Next app, open up react dev tools and inspect the Box component, rendered by Every time react-devtools-extensions 23.0- Could not find ID for Fiber \"App\"\nHey, thanks for reporting this issue, and sorry it's blocking your workflow. Edit: The reason for this issue seems to be that there are multiple instances, and the one that we are using to get the fiber's ID when we inspect doesn't have the App fiber (a recursive owner of Box). We'll look into why this is occurring soon!\nFixed via", "positive_passages": [{"docid": "doc-en-react-da120b7e0725ab8a782b8d12544aaf93710fe82176d87f4d0f79458431b6ce82", "text": "}; } <ins> // Map of one or more Fibers in a pair to their unique id number. // We track both Fibers to support Fast Refresh, // which may forcefully replace one of the pair as part of hot reloading. // In that case it's still important to be able to locate the previous ID during subsequent renders. const fiberToIDMap: Map<Fiber, number> = new Map(); // Map of id to one (arbitrary) Fiber in a pair. // This Map is used to e.g. get the display name for a Fiber or schedule an update, // operations that should be the same whether the current and work-in-progress Fiber is used. const idToArbitraryFiberMap: Map<number, Fiber> = new Map(); </ins> export function attach( hook: DevToolsHook, rendererID: number,", "commid": "react_pr_24116"}], "negative_passages": []}
{"query_id": "q-en-react-920fef893a94a75d7ab860855565a3ba08a6269c1ccfa2b0b833352987401c3f", "query": "Run the Next app, open up react dev tools and inspect the Box component, rendered by Every time react-devtools-extensions 23.0- Could not find ID for Fiber \"App\"\nHey, thanks for reporting this issue, and sorry it's blocking your workflow. Edit: The reason for this issue seems to be that there are multiple instances, and the one that we are using to get the fiber's ID when we inspect doesn't have the App fiber (a recursive owner of Box). We'll look into why this is occurring soon!\nFixed via", "positive_passages": [{"docid": "doc-en-react-ecce357993719897be62100601c9a51b819404a4c2aae90fc9416f3bb0342de1", "text": "} } <del> // Map of one or more Fibers in a pair to their unique id number. // We track both Fibers to support Fast Refresh, // which may forcefully replace one of the pair as part of hot reloading. // In that case it's still important to be able to locate the previous ID during subsequent renders. const fiberToIDMap: Map<Fiber, number> = new Map(); // Map of id to one (arbitrary) Fiber in a pair. // This Map is used to e.g. get the display name for a Fiber or schedule an update, // operations that should be the same whether the current and work-in-progress Fiber is used. const idToArbitraryFiberMap: Map<number, Fiber> = new Map(); </del> // When profiling is supported, we store the latest tree base durations for each Fiber. // This is so that we can quickly capture a snapshot of those values if profiling starts. // If we didn't store these values, we'd have to crawl the tree when profiling started,", "commid": "react_pr_24116"}], "negative_passages": []}
{"query_id": "q-en-react-f3f1dd8e70cf3bdc2ac706095a9ff8bd29921c5cf0d0a8cb5995da5150eebd57", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: Current main branch the repository from the main branch node and yarn (node version: 16.14.0, yarn version: 1.22.17, JDK version: tried both 11 and 17) yarn yarn build <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Error message : <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --No error messages from rollup. Success in yarn build.\nIf rollup is crashing during the build process, that's a rollup problem.\nYes, that was what my colleagues and I are thinking too. Then shouldn't something change related to Rollup, like going back to the previous version of code, or another way to resolve the error in the react project?\nExactlly it's the problem of Rollup and already fix it two years ago. See\nThis issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, \"bump\"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!", "positive_passages": [{"docid": "doc-en-react-a395c62a2e69225a8d30c2d8744ac4942efd3944e763ca3f3ffd00c45eaee487", "text": "visitor: { CallExpression: function(path, file) { <del> if (file.filename.indexOf('shared/assign') !== -1) { </del> <ins> if (/shared(/|)assign/.test(file.filename)) { </ins> // Don't replace Object.assign if we're transforming shared/assign return; }", "commid": "react_pr_24318"}], "negative_passages": []}
{"query_id": "q-en-react-f3f1dd8e70cf3bdc2ac706095a9ff8bd29921c5cf0d0a8cb5995da5150eebd57", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: Current main branch the repository from the main branch node and yarn (node version: 16.14.0, yarn version: 1.22.17, JDK version: tried both 11 and 17) yarn yarn build <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Error message : <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --No error messages from rollup. Success in yarn build.\nIf rollup is crashing during the build process, that's a rollup problem.\nYes, that was what my colleagues and I are thinking too. Then shouldn't something change related to Rollup, like going back to the previous version of code, or another way to resolve the error in the react project?\nExactlly it's the problem of Rollup and already fix it two years ago. See\nThis issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, \"bump\"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!\nClosing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!", "positive_passages": [{"docid": "doc-en-react-aec52fd5a50100403a2ca8d5e17a508572f62340330f59bf6cdc31f5d836f52a", "text": "}, MemberExpression: function(path, file) { <del> if (file.filename.indexOf('shared/assign') !== -1) { </del> <ins> if (/shared(/|)assign/.test(file.filename)) { </ins> // Don't replace Object.assign if we're transforming shared/assign return; }", "commid": "react_pr_24318"}], "negative_passages": []}
{"query_id": "q-en-react-731a9b0ecc107b0b5f7010992e2325f27abd085b954af932a81d20fb99b53ea2", "query": "When trying to build the [(]) locally: react yarn build-for-devtools from the root repo node version: v16.16.0.\nThis is the result of :\nYarn is the package manager of choice in this repository. Did you run from the root first?\nI did not do that as I dont usually work with yarn. I will try now. Please reject my bug and thanks for your time. I feel a bit stupid.\nIm trying it now, and it looks like its working. It would be great if someone adds this to the readme of the extension repo.\nSorry to hear. We definitely want to avoid that. You're absolutely right. I'm on it.\nPlease note also that they ask to do: . The command has , which doesnt work for windows and should be replaced by . This is the command:", "positive_passages": [{"docid": "doc-en-react-58e999de02c89fa09fba510b574c1676ac6b2c9276f554b2d3e9db47c5cc9242", "text": "<sup>1</sup> Note that at this time, an _experimental_ build is required because DevTools depends on the `createRoot` API. <ins> To install all necessary dependencies, run the following command from the root of the repository: ```sh yarn install ``` </ins> #### Build from source To build dependencies from source, run the following command from the root of the repository: ```sh", "commid": "react_pr_25053"}], "negative_passages": []}
{"query_id": "q-en-react-4bc89deb90dbfbd81c5a981f7082d367af41474b4e0980739d6c1413b1d264ad", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: 18.3.0-canary-- SSR app that has images in its tree using renderToString or renderToPipeableStream <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Link to code example: <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --! To not insert preloads randomly. Note that there is difference between renderToString and renderToPipeableStream, renderToString the preloads appear inside root and renderToPipeableStream they appear in head. Sorry this is a bit of a question rather than bug report maybe, I have searched around and cannot see any mention of auto-preloading images but I assume there must be something going on that I have missed. I was able to fix by using .\nThis. Tested with . It would be \"kinda\" tolerable for the LCP image above fold (featured image or similar), but we have lots of lazy loaded images below fold which contain <noscriptalternatives like: For every tag used in noscript, the image is preloaded in which completely defies the purpose of lazy loading.\nI think this is actually now expected behaviour, after digging the source a bit I found Though I could not find any docs/release notes that mention this which is a little odd as now you need to explicitly think about the loading strategy of every img tag you use. For me I was able to \"fix\" this by making sure all our img tags have either loading=lazy or fetchPriority=low when they are not to be preloaded, this gave me more or less only the LCP images preloaded. For your case you could either add loading=lazy or fetchPriority=low to the fallback images, though depending on your target browsers you could get rid of the noscript parts these days as loading=lazy has pretty wide browser support now. Would be good to have this documented somewhere and also maybe add this to the react linter.\nThanks for the info regarding loading=lazy, that could solve it. If this is really a \"feature\", I have to say, I don't think it should be React's business to put stuff into my automagically\u2026\nWhich framework are you using?\nFor me, its Remix.\nYou're probably using their image component that uses . Or they're doing calls some other way. Can you open an issue on their issue tracker first to clarify?\nI'm not using their image component but , but I will take a look at Remix & React Router code, whether they call this somewhere and open an issue. Interestingly, this behavior is only applied by Remix (or happens for some reason), when upgrading to React canary.\nReact is adding support for Suspensey \"resource\". For instance if you render a stylesheet and opt into React's handling of this using \"precedence\" then commits which contain this stylesheet will wait to commit until the sheet has loaded. Another area that we're making Suspensey is images. Lazy images indicate that they do not require suspense coordination but by default images will (in the future) block a boundary reveal until the image has loaded and been decoded. While these features are for client updates there are analogs for SSR. for stylesheets browsers already block paint until stylesheets load in the head. They don't however do this for images. React canaries now preload the first few images rendered if they are not lazy because we want to mimic the coordinated reveal of Suspensey images along with the first paint. It's not a perfect heuristic because it's not actually enforced to be coordinated but it does better align the behavior across suspensy vs lazy images. Another way you can signal to React that an image is not expected to be part of the first paint is to set the fetchPriority to \"low\"\nFor every <imgtag used in noscript, the image is preloaded in <headwhich completely defies the purpose of lazy loading. This is a genuine bug. will land a fix\nGood to know, thanks for the explanation.\nfwiw no framework used just renderToPipeableStream, in my case I was able to add low priority to a few icon images to get the preload to load reasonable candidates. Would be good to be able to opt-out of this somehow for a boundary, thinking of the case where you are waiting on component/data to load and don't really care about the image but lazy loading would be inappropriate for an above the fold larger image. Maybe even a way to modify the heuristic via some sort of callback would be useful.", "positive_passages": [{"docid": "doc-en-react-c6045bef889e2329a2fa65f567731aab94d134f62191165ee18c44cf2215351b", "text": "props: Object, resumableState: ResumableState, renderState: RenderState, <del> pictureTagInScope: boolean, </del> <ins> pictureOrNoScriptTagInScope: boolean, </ins> ): null { const {src, srcSet} = props; if (", "commid": "react_pr_28815"}], "negative_passages": []}
{"query_id": "q-en-react-4bc89deb90dbfbd81c5a981f7082d367af41474b4e0980739d6c1413b1d264ad", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: 18.3.0-canary-- SSR app that has images in its tree using renderToString or renderToPipeableStream <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Link to code example: <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --! To not insert preloads randomly. Note that there is difference between renderToString and renderToPipeableStream, renderToString the preloads appear inside root and renderToPipeableStream they appear in head. Sorry this is a bit of a question rather than bug report maybe, I have searched around and cannot see any mention of auto-preloading images but I assume there must be something going on that I have missed. I was able to fix by using .\nThis. Tested with . It would be \"kinda\" tolerable for the LCP image above fold (featured image or similar), but we have lots of lazy loaded images below fold which contain <noscriptalternatives like: For every tag used in noscript, the image is preloaded in which completely defies the purpose of lazy loading.\nI think this is actually now expected behaviour, after digging the source a bit I found Though I could not find any docs/release notes that mention this which is a little odd as now you need to explicitly think about the loading strategy of every img tag you use. For me I was able to \"fix\" this by making sure all our img tags have either loading=lazy or fetchPriority=low when they are not to be preloaded, this gave me more or less only the LCP images preloaded. For your case you could either add loading=lazy or fetchPriority=low to the fallback images, though depending on your target browsers you could get rid of the noscript parts these days as loading=lazy has pretty wide browser support now. Would be good to have this documented somewhere and also maybe add this to the react linter.\nThanks for the info regarding loading=lazy, that could solve it. If this is really a \"feature\", I have to say, I don't think it should be React's business to put stuff into my automagically\u2026\nWhich framework are you using?\nFor me, its Remix.\nYou're probably using their image component that uses . Or they're doing calls some other way. Can you open an issue on their issue tracker first to clarify?\nI'm not using their image component but , but I will take a look at Remix & React Router code, whether they call this somewhere and open an issue. Interestingly, this behavior is only applied by Remix (or happens for some reason), when upgrading to React canary.\nReact is adding support for Suspensey \"resource\". For instance if you render a stylesheet and opt into React's handling of this using \"precedence\" then commits which contain this stylesheet will wait to commit until the sheet has loaded. Another area that we're making Suspensey is images. Lazy images indicate that they do not require suspense coordination but by default images will (in the future) block a boundary reveal until the image has loaded and been decoded. While these features are for client updates there are analogs for SSR. for stylesheets browsers already block paint until stylesheets load in the head. They don't however do this for images. React canaries now preload the first few images rendered if they are not lazy because we want to mimic the coordinated reveal of Suspensey images along with the first paint. It's not a perfect heuristic because it's not actually enforced to be coordinated but it does better align the behavior across suspensy vs lazy images. Another way you can signal to React that an image is not expected to be part of the first paint is to set the fetchPriority to \"low\"\nFor every <imgtag used in noscript, the image is preloaded in <headwhich completely defies the purpose of lazy loading. This is a genuine bug. will land a fix\nGood to know, thanks for the explanation.\nfwiw no framework used just renderToPipeableStream, in my case I was able to add low priority to a few icon images to get the preload to load reasonable candidates. Would be good to be able to opt-out of this somehow for a boundary, thinking of the case where you are waiting on component/data to load and don't really care about the image but lazy loading would be inappropriate for an above the fold larger image. Maybe even a way to modify the heuristic via some sort of callback would be useful.", "positive_passages": [{"docid": "doc-en-react-c239fde2a9974ba1dd2cf83f4c6e2a1e69da5df51eb66f4feb220e49181e8a61", "text": "(typeof src === 'string' || src == null) && (typeof srcSet === 'string' || srcSet == null) && props.fetchPriority !== 'low' && <del> pictureTagInScope === false && </del> <ins> pictureOrNoScriptTagInScope === false && </ins> // We exclude data URIs in src and srcSet since these should not be preloaded !( typeof src === 'string' &&", "commid": "react_pr_28815"}], "negative_passages": []}
{"query_id": "q-en-react-4bc89deb90dbfbd81c5a981f7082d367af41474b4e0980739d6c1413b1d264ad", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: 18.3.0-canary-- SSR app that has images in its tree using renderToString or renderToPipeableStream <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Link to code example: <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --! To not insert preloads randomly. Note that there is difference between renderToString and renderToPipeableStream, renderToString the preloads appear inside root and renderToPipeableStream they appear in head. Sorry this is a bit of a question rather than bug report maybe, I have searched around and cannot see any mention of auto-preloading images but I assume there must be something going on that I have missed. I was able to fix by using .\nThis. Tested with . It would be \"kinda\" tolerable for the LCP image above fold (featured image or similar), but we have lots of lazy loaded images below fold which contain <noscriptalternatives like: For every tag used in noscript, the image is preloaded in which completely defies the purpose of lazy loading.\nI think this is actually now expected behaviour, after digging the source a bit I found Though I could not find any docs/release notes that mention this which is a little odd as now you need to explicitly think about the loading strategy of every img tag you use. For me I was able to \"fix\" this by making sure all our img tags have either loading=lazy or fetchPriority=low when they are not to be preloaded, this gave me more or less only the LCP images preloaded. For your case you could either add loading=lazy or fetchPriority=low to the fallback images, though depending on your target browsers you could get rid of the noscript parts these days as loading=lazy has pretty wide browser support now. Would be good to have this documented somewhere and also maybe add this to the react linter.\nThanks for the info regarding loading=lazy, that could solve it. If this is really a \"feature\", I have to say, I don't think it should be React's business to put stuff into my automagically\u2026\nWhich framework are you using?\nFor me, its Remix.\nYou're probably using their image component that uses . Or they're doing calls some other way. Can you open an issue on their issue tracker first to clarify?\nI'm not using their image component but , but I will take a look at Remix & React Router code, whether they call this somewhere and open an issue. Interestingly, this behavior is only applied by Remix (or happens for some reason), when upgrading to React canary.\nReact is adding support for Suspensey \"resource\". For instance if you render a stylesheet and opt into React's handling of this using \"precedence\" then commits which contain this stylesheet will wait to commit until the sheet has loaded. Another area that we're making Suspensey is images. Lazy images indicate that they do not require suspense coordination but by default images will (in the future) block a boundary reveal until the image has loaded and been decoded. While these features are for client updates there are analogs for SSR. for stylesheets browsers already block paint until stylesheets load in the head. They don't however do this for images. React canaries now preload the first few images rendered if they are not lazy because we want to mimic the coordinated reveal of Suspensey images along with the first paint. It's not a perfect heuristic because it's not actually enforced to be coordinated but it does better align the behavior across suspensy vs lazy images. Another way you can signal to React that an image is not expected to be part of the first paint is to set the fetchPriority to \"low\"\nFor every <imgtag used in noscript, the image is preloaded in <headwhich completely defies the purpose of lazy loading. This is a genuine bug. will land a fix\nGood to know, thanks for the explanation.\nfwiw no framework used just renderToPipeableStream, in my case I was able to add low priority to a few icon images to get the preload to load reasonable candidates. Would be good to be able to opt-out of this somehow for a boundary, thinking of the case where you are waiting on component/data to load and don't really care about the image but lazy loading would be inappropriate for an above the fold larger image. Maybe even a way to modify the heuristic via some sort of callback would be useful.", "positive_passages": [{"docid": "doc-en-react-407cc3cea5e677e2412b4e57a0c1c47616f3fe8b27fdd5cbea4c56f950c822fe", "text": "props, resumableState, renderState, <del> !!(formatContext.tagScope & PICTURE_SCOPE), </del> <ins> !!(formatContext.tagScope & (PICTURE_SCOPE | NOSCRIPT_SCOPE)), </ins> ); } // Omitted close tags", "commid": "react_pr_28815"}], "negative_passages": []}
{"query_id": "q-en-react-4bc89deb90dbfbd81c5a981f7082d367af41474b4e0980739d6c1413b1d264ad", "query": "<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. --React version: 18.3.0-canary-- SSR app that has images in its tree using renderToString or renderToPipeableStream <!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. --Link to code example: <!-- Please provide a CodeSandbox (), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: --! To not insert preloads randomly. Note that there is difference between renderToString and renderToPipeableStream, renderToString the preloads appear inside root and renderToPipeableStream they appear in head. Sorry this is a bit of a question rather than bug report maybe, I have searched around and cannot see any mention of auto-preloading images but I assume there must be something going on that I have missed. I was able to fix by using .\nThis. Tested with . It would be \"kinda\" tolerable for the LCP image above fold (featured image or similar), but we have lots of lazy loaded images below fold which contain <noscriptalternatives like: For every tag used in noscript, the image is preloaded in which completely defies the purpose of lazy loading.\nI think this is actually now expected behaviour, after digging the source a bit I found Though I could not find any docs/release notes that mention this which is a little odd as now you need to explicitly think about the loading strategy of every img tag you use. For me I was able to \"fix\" this by making sure all our img tags have either loading=lazy or fetchPriority=low when they are not to be preloaded, this gave me more or less only the LCP images preloaded. For your case you could either add loading=lazy or fetchPriority=low to the fallback images, though depending on your target browsers you could get rid of the noscript parts these days as loading=lazy has pretty wide browser support now. Would be good to have this documented somewhere and also maybe add this to the react linter.\nThanks for the info regarding loading=lazy, that could solve it. If this is really a \"feature\", I have to say, I don't think it should be React's business to put stuff into my automagically\u2026\nWhich framework are you using?\nFor me, its Remix.\nYou're probably using their image component that uses . Or they're doing calls some other way. Can you open an issue on their issue tracker first to clarify?\nI'm not using their image component but , but I will take a look at Remix & React Router code, whether they call this somewhere and open an issue. Interestingly, this behavior is only applied by Remix (or happens for some reason), when upgrading to React canary.\nReact is adding support for Suspensey \"resource\". For instance if you render a stylesheet and opt into React's handling of this using \"precedence\" then commits which contain this stylesheet will wait to commit until the sheet has loaded. Another area that we're making Suspensey is images. Lazy images indicate that they do not require suspense coordination but by default images will (in the future) block a boundary reveal until the image has loaded and been decoded. While these features are for client updates there are analogs for SSR. for stylesheets browsers already block paint until stylesheets load in the head. They don't however do this for images. React canaries now preload the first few images rendered if they are not lazy because we want to mimic the coordinated reveal of Suspensey images along with the first paint. It's not a perfect heuristic because it's not actually enforced to be coordinated but it does better align the behavior across suspensy vs lazy images. Another way you can signal to React that an image is not expected to be part of the first paint is to set the fetchPriority to \"low\"\nFor every <imgtag used in noscript, the image is preloaded in <headwhich completely defies the purpose of lazy loading. This is a genuine bug. will land a fix\nGood to know, thanks for the explanation.\nfwiw no framework used just renderToPipeableStream, in my case I was able to add low priority to a few icon images to get the preload to load reasonable candidates. Would be good to be able to opt-out of this somehow for a boundary, thinking of the case where you are waiting on component/data to load and don't really care about the image but lazy loading would be inappropriate for an above the fold larger image. Maybe even a way to modify the heuristic via some sort of callback would be useful.", "positive_passages": [{"docid": "doc-en-react-a4561cbd06488d43ee47bd173fcd15b1fb301fb8d74cce4a0175781ebda8c661", "text": "); }); <ins> // Fixes: https://github.com/facebook/react/issues/27910 it('omits preloads for images inside noscript tags', async () => { function App() { return ( <html> <body> <img src=\"foo\" /> <noscript> <img src=\"bar\" /> </noscript> </body> </html> ); } await act(() => { renderToPipeableStream(<App />).pipe(writable); }); expect(getMeaningfulChildren(document)).toEqual( <html> <head> <link rel=\"preload\" href=\"foo\" as=\"image\" /> </head> <body> <img src=\"foo\" /> <noscript>&lt;img src=\"bar\"&gt;</noscript> </body> </html>, ); }); </ins> it('should handle media on image preload', async () => { function App({isClient}) { ReactDOM.preload('/server', {", "commid": "react_pr_28815"}], "negative_passages": []}