toolkitchen/polyfills — pull request #88 by arv (2013-02-25 20:49:16+00:00)
Title: ShadowDOM V2 Polyfill

"Showing 30 changed files with 1,698 additions and 1,612 deletions."

This is most likely too large to actually review :'(

Here is a short summary of how this works.

Each real DOM `Node` is represented by a wrapper object: `WrapperNode`, `WrapperHTMLElement`, `WrapperDocumentFragment` etc

`ShadowRenderer` uses `visual.*` to mutate the DOM which updates the wrapper node's internal pointers so that the logical DOM tree is kept intact.

When the logical tree structure changes `WrapperNode.prototype.invalidateShadowRenderer` is called. It marks the renderer as dirty and schedules a call to `ShadowRenderer.prorotype.render` at the next rAF (TODO use end of microtask)

Each DOM class is represented by a wrapper class. These are mostly built using reflection but some methods have been hand written to invalidate the `ShadowRenderer` as well as to ensure the logical tree structure is kept correct. In those cases the underlying real DOM `Node` is accessed using `unwrap` and to get the wrapper `wrap` is used. At the moment we also use `wrapper.node`