Closed ShikiOkasaka closed 11 years ago
Conditions such as "the element is popped off the stack of open elements of an HTML parser" are not associated with any DOM event and must be handled differently. Adding a virtual function like notify() to ElementImp would be an easy way to do so.
We also need to implement a task queue for tasks from the DOM manipulation task source and so on.
132158e40cf7d5610e87f0de65a866a58a377dee implements the above mentioned notify() method to ElementImp.
b04cf5460f07cda2ddbcb1fd13102fefb935ebac implements the event loops for reacting to DOM manipulation, etc.
At this point, both the link and object elements should be able to be implemented without using eval().
HTMLElementImp::eval() has been used to perform additional operations for each element inserted into the DOM tree. Most of them can be processed by mutation callbacks and fixed in issue #12.
Note even though the spec says, "DOM mutation events must not fire for changes caused by the UA parsing the document. This includes the parsing of any content inserted using document.write() and document.writeln() calls." - http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#tree-construction we still need to fire DOM mutation events from the parser for _DEFAULTPHASE (not for other phases). As we'll switching over to Mutation observers, this might be changed as well.
The remaining elements that still use eval() are the link and object elements.
As for the link element, resources can be obtained later rather than just after the element is parsed: "User agents may opt to only try to obtain such resources when they are needed, instead of pro-actively fetching all the external resources that are not applied." - http://www.w3.org/TR/html5/document-metadata.html#concept-link-obtain
As for the object element, the conditions to execute steps similar to eval() are listed in the paragraph starting with "Whenever one of the following conditions occur:" in, http://www.w3.org/TR/html5/embedded-content-0.html#the-object-element