Correct changing readyState and script running order#1920
Correct changing readyState and script running order#1920sttk wants to merge 4 commits intojsdom:mainfrom sttk:ready_state
Conversation
|
Thanks! However, this does not follow the guidelines in CONTRIBUTING.md for introducing new tests. Also, I am not happy with the code structuring here which modifies the global event handlers implementation to add a special case. You should be able to make it work without that. |
|
Sorry, maybe I wasn't clear. This should be tested using web-platform-tests (which we can then run against browsers), not mocha tests. And this should not impact the general event handler implementation (onxxx) at all; it should instead use the same eventing mechanism as anything else. There is nothing in the spec that corresponds to the special-case algorithm you are introducing for onload, so we shouldn't put anything in jsdom. In general, please try to implement the spec. |
|
This issue which should be solved by this pr consists of five sub issues:
Refs. |
|
I've modified the codes about the above 1,2,3,5 for this issue with new ResourceQueue. -- |
This changes the HTML parsing infrastructure, in particular how we interface with parse5. The original motivation for this change was increased performance; the new benchmark, which appends 65535 <tr>s, gets a speedup of ~3x from these changes. Other user-visible changes to script evaluation might be present. In particular, the tests revealed that one document.write-related test that used to somehow pass now fails, while another one succeeds (at least on Node 8). In most cases, however, behavior should be the same. While here, we also changed style sheets to reevaluate their rules and update styleEl.sheet or linkEl.sheet appropriately when their child text content changed. Behind the scenes details: - We now use a parse5 tree adapter directly for parsing, instead of using the htmlparser2 adapter layer (which had an O(n) insertion cost for new siblings) - SAX XML parsing code has been simplified by no longer being shared with parse5/htmlparser2 parsing code. - Nodes no longer have a reference to the "core" god-object. This was only used in a couple places, and was error prone because this reference was not available in cases such as document nodes created via the Document constructor. This removes a lot of code that threaded the object throughout everything. - We continued to use hacky workarounds for script evaluation, during parsing and elsewhere. Perhaps one day, inspired by #1316 and #1920, we can fix these.
JSDOM is different from Web browsers about changing
document.readyStateand the order of running scripts.This pr is for modifying this issue.
A sample HTML:
The result by Chrome, Firefox, Edge, IE is as follows:
The result by JSDOM before modified is as follows: