-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-parsing of parser-produced HTML causes change of document semantics #1280
Comments
This is indeed a problem. Unfortunately we can't change how the original markup is parsed. Your proposed workaround also doesn't help in general. Consider Also, come to think of it, foster parenting can also cause nested |
But at least, nested |
We can remove association on foster parenting if |
Whether things work just fine is very much dependent on what the page is doing. Pages break completely for seemingly minor things. My example doesn't do foster parenting. But also breaking form association or moving form controls in the DOM is certainly going to break pages. Note that legacy IE did usually roundtrip form association (but it didn't use a tree for the DOM), and it was a known problem that form association didn't work with innerHTML. But it was rare enough that browsers got away with breaking it. |
Indeed,
So, I guess we don't have any options left except keeping it as is? |
Can't we change serialization algorithm itself? |
How? |
That's another question 😄 |
I think we basically can't change the spec to fix this. It would require substantial changes with high risk of breaking Web compat. However the spec can do a better job of pointing out that this issue exists and maybe what can be done about it outside of the browser itself, similar to https://html.spec.whatwg.org/multipage/syntax.html#coercing-an-html-dom-into-an-infoset |
Consider we have following markup:
it will be parsed as:
This is invalid markup, but it works just fine in DOM representation.
Now if you serialize it back to HTML and re-parse it, e.g. doing:
You will get:
Which completely changes semantics of document: input now has associated form with
url1
.As a possible workaround we can add foster parenting-style algorithm for forms: we will just bailout any nested
form
s.The text was updated successfully, but these errors were encountered: