{"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": " /** * 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 ; } }); expect(ReactDescriptor.isValidDescriptor()).toEqual(true); expect(ReactDescriptor.isValidDescriptor( ensureScrollValueMonitoring: function() { if (!isMonitoringScrollValue) { ensureScrollValueMonitoring: function(){ if (hasEventPageXY === undefined) { hasEventPageXY = document.createEvent && 'pageX' in document.createEvent('MouseEvent'); } if (!hasEventPageXY && !isMonitoringScrollValue) { 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, headers: null, 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'); var warning = require('warning'); 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": "} } // 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: ' + '' ); 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 = ` var converter = new Showdown.converter(); 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": "
`This is ``another`` comment`
`\". 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: React is flexible and provides hooks that allow you to interface with other libraries and frameworks. This example uses Showdown, an external other libraries and frameworks. This example uses **marked**, an external Markdown library, to convert the textarea's value in real-time.
\"+(escaped?code:escape(code,true))+\"n\"}return''+(escaped?code:escape(code,true))+\"nn\"};Renderer.prototype.blockquote=function(quote){return\"n\"+quote+\"n\"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return\"
\"+text+\"
n\"};Renderer.prototype.table=function(header,body){return\"\"+text+\"\"};Renderer.prototype.br=function(){return this.options.xhtml?\"\"+escape(e.message+\"\",true)+\"\"}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)}());
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.: //
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 ` Just type 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 tags. // var end = grafs.length; for (var i=0; i \"); str += \"
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/!$](\"[^\"]*\"|'[^']*'|[^'\">])*>|)/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 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 = \"\" + link_text + \"\"; return result; } var _DoImages = function(text) { // // Turn Markdown image shortcuts into 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:  // 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,\""\"); url = escapeCharacters(url,\"*_\"); var 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('
' + _RunSpanGamut(m1) + \"
\");}); text = text.replace(/^(.+)[ t]*n-+[ t]*n+/gm, function(matchFound,m1){return hashBlock('' + _RunSpanGamut(m1) + \"
\");}); // 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(\"` 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 = \"
\"; 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 \" + codeblock + \"n 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 foo `bar` baz at the prompt.`bar` ... // /* 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+\"\"+c+\"\"; }); 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,\"&\"); // Do the angle bracket song and dance: text = text.replace(//g,\">\"); // 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) { // must go first: text = text.replace(/(**|__)(?=S)([^r]*?S[*_]*)1/g, \"$2\"); text = text.replace(/(*|_)(?=S)([^r]*?S)1/g, \"$2\"); 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 content, so we need to fix that: bq = bq.replace( /(s*
[^r]+?
)/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(\"n\" + bq + \"n
\"); }); return text; } var _FormParagraphs = function(text) { // // Params: // $text - string to process with html var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true); this._render(element, transaction, context); ReactUpdates.ReactReconcileTransaction.release(transaction); ReactUpdates.batchedUpdates(_batchedRender, this, element, context); return this.getRenderOutput(); }; function _batchedRender(renderer, element, context) { var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true); renderer._render(element, transaction, context); ReactUpdates.ReactReconcileTransaction.release(transaction); } 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'); }); it('can setState in componentWillMount when shallow rendering', function() { var SimpleComponent = React.createClass({ componentWillMount() { this.setState({groovy: 'doovy'}); }, render() { return ```html ``` ```html ``` 2. In some other code (typically event handler code), access the **backing instance** via `this.refs` as in: ```javascript this.refs.myInput ``` ```javascript this.refs.myInput ``` 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: ```html ``` ```html render: function() { return typeof window.dispatchEvent === 'function' && typeof Event === 'function') { typeof window.dispatchEvent === 'function') { var fakeNode = document.createElement('react'); ReactErrorUtils.invokeGuardedCallback = function(name, func, a, b) { var boundFunc = func.bind(null, a, b); fakeNode.addEventListener(name, boundFunc, false); fakeNode.dispatchEvent(new Event(name)); var evt = document.createEvent('Event'); evt.initEvent(name, false, false); fakeNode.dispatchEvent(evt); 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`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn't callable.' '`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 ); 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`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn't callable.' '`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 ); 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 = { value: typeof linkType === 'undefined' ? value: linkType === undefined ? 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. if (typeof initialState === 'undefined' && if (initialState === undefined && 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) { if (typeof props[propName] === 'undefined') { if (props[propName] === undefined) { 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; if (typeof offsets.end === 'undefined') { if (offsets.end === undefined) { 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); var end = typeof offsets.end === 'undefined' ? var end = offsets.end === undefined ? 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; if (typeof end === 'undefined') { if (end === undefined) { 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( typeof inst.props === 'undefined' || !propsMutated, inst.props === undefined || !propsMutated, '%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( typeof shouldUpdate !== 'undefined', shouldUpdate !== undefined, '%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. if (typeof renderedComponent === 'undefined' && if (renderedComponent === undefined && 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'; // NOTE: We're explicitly not using JSX in this file. This is intended to test // classic JS without JSX. 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'); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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'); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. it('is indistinguishable from a plain object', function() { var element = React.createElement('div', {className: 'foo'}); var object = {}; expect(element.constructor).toBe(object.constructor); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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'); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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); }); // NOTE: We're explicitly not using JSX here. This is intended to test // classic JS without JSX. 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: expect(isTagStackValid(['body', 'body'])).toBe(false); expect(isTagStackValid(['svg', 'foreignObject', 'body', 'p'])).toBe(false); }); });", "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:
case 'body': 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:
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 '
result.args = JSON.stringify(item.args);