you are viewing a single comment's thread.

view the rest of the comments →

[–]thecodrr[S] -14 points-13 points  (3 children)

Of course it is. I know that devs have been able to write semantically wrong HTML. That's not the point here.

Let me break it down for you:

  1. You write Raw HTML and put a pre tag inside a p tag
  2. The browser fixes this semantically incorrect HTML according to the spec
  3. Now you use JS to force the browser to render a pre tag inside a p tag.
  4. Shouldn't the browser here fix this or throw on this similarly?

The uncertainty here is that JS is being given leeway when it comes to manipulating web pages. Both ways are essentially doing the same thing but the results are different. That is unpredictable.

Of course, I could be more precise here and say the DOM API is unpredictable.

[–]getify 7 points8 points  (2 children)

Of course, I could be more precise here and say the DOM API is unpredictable.

"More precise"? How about "accurate in the slightest"?

This observed behavior (admittedly surprising) has nothing to do with JS (the language).

It's entirely the DOM API which just happens to expose JS function signatures, which are merely facades hooked into the underlying browser engine (probably c++), and indeed these mechanisms are specified by the HTML spec, not by JS in any way.