Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Performance optimizations #216

Merged
merged 20 commits into from
Mar 16, 2018
Merged

Performance optimizations #216

merged 20 commits into from
Mar 16, 2018

Conversation

sorvell
Copy link
Contributor

@sorvell sorvell commented Mar 15, 2018

  • for native tree access prefer using captured native accessors on IE/Edge because they are faster than TreeWalker.
  • make ShadowRoot a bespoke object with DocumentFragment's prototype rather than an instance of DocumentFragment because it's faster to create.
  • some micro-opts to adding nodes

Steven Orvell added 13 commits October 13, 2017 10:27
On some platforms, notably Edge/IE, treewalker is slower than native getters. Therefore prefer native getters when they can be used.
Never directly access shady data storage.
* appendChild avoids looking up ownerRoot in some cases
* using native descriptors now explicitly settable
* native `isConnected` used where available.
On IE/Edge treewalker is especially slow, but on Chrome/FF/Safari they are marginally faster.
As a performance optimization, ShadowRoot is now not a proper DocumentFragment instance but a bespoke object with DocumentFragment's prototype in its prototype chain.
Also fix textContent setter to fast path to native impl for untracked nodes.
@ruud
Copy link

ruud commented Mar 15, 2018

whoh, looking forward to having this in !!

Steven Orvell added 7 commits March 15, 2018 10:38
* must remove children to handle slot removal.
* slot removal must clear assigned/flattened nodes.
* make exposed querySelector work with .call for compat
* expose shadowed properties on ShadowRoot with correct values
* use native accessors on Edge as well as IE
Adds `ShadyDOM.patch` to manually patch a node instance on old Chrome/Safari that do not have prototype accessors. This is needed when `textContent` or `innerHTML` is set on a node in a shadowRoot and a `<slot>` is added/removed. (Added this to `Limitations` section in Readme.)
Copy link
Contributor

@dfreedm dfreedm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Moving all the weird shady data from adhoc into class is great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants