mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
* Warn for text content * Warn for different attributes/properties values Warns if there are unknown extra attributes in the hydrated node. It also tries to compare the existing property or attribute against the expected value. It does this by reading the property and comparing it to the prop. Except it's not that simple because multiple prop values can yield the same output. For this we pass an extra expected value that is a hint as to which one was used. This is a bit weird but I'm not sure the alternatives were much better. * Warn when there is an insertion or deletion during hydration This warns if there is ever an insertion or deletion due to hydration failing to find a match. Currently we can't warn for insertions required into the root because that's how we do all non-hydrating renders atm. Left a todo. This strategy is a bit unfortunate that it leads to so much plumbing code. And we have to add three extra methods to the HostConfig that are only used in DEV and not for anything else. I don't really have a better idea. * Don't try to delete children of a textarea Textareas are special cases. The initial mount inserts children as the default value, but we should leave that untouched. This is the same as the special case where we set text content of children so I'll use that mechanism. * Change expected format for text differences In Stack this is presented as HTML which needs to have normalized escaping rules. In Fiber it is currently not presented as HTML but a raw string so we don't escape it. * Unmount component in between tests In Fiber, the second warning isn't issued because it's considered an update not a new initial render and we don't fire the warning for those. * Change expectation of white space text behavior in Fiber In Fiber we don't expect empty strings to be different from rendering null. In fact, in a follow up I plan on formalizing this by never creating text Fibers for empty strings. * Warn for different dangerouslySetInnerHTML We can't just compare the raw innerHTML value because it will have been normalized. Instead, we'll create another element, set its innerHTML and read it back. Since there can be custom elements registered with this document, we want to avoid any side-effects they might cause. So I do this in a fresh new document. I'm not sure how this would affect controlled components and other stuff that could have changed after runtime. I think for those cases maybe we just need a general way of opting out of the diff.