PolymerLabs/part-theme

Name: part-theme

Owner: PolymerLabs

Description: Experimental proof of concept shim for ::part/::theme css.

Created: 2017-10-17 00:53:08.0

Updated: 2018-02-27 10:12:23.0

Pushed: 2018-02-06 18:51:59.0

Homepage: null

Size: 9

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

part-theme

This is an experimental proof of concept shim for ::part or ::theme as defined here https://tabatkins.github.io/specs/css-shadow-parts/.

PartThemeMixin should be applied to any elements that define or consume css. Elements may instead just call applyPartTheme(element) to avoid use of the mixin.

Known Issues
Performance

Performance will likely be sub-optimal due to instance level work done to support parts.

  1. Element's styles are parsed for ::part/::theme selectors. These are re-written using css custom properties.

  2. Element's shadowRoot dom is scanned for elements with part attributes. A new style element is added with rules that match these attributes corresponding to part properties provided as css custom properties from the element ancestor.

NOTE: Any time dom is modified in the element containing part attributes, _applyPartTheme must be called. This is done automatically only when the element is connected.

Future optimization
  1. Support for ::theme requires traversing the entire ancestor tree. Dropping support for ::theme would remove this requirement and then ancestor traversal would only be required for forwarding (foo => forwarded-foo).
  2. Currently css is unique for every element instance but unique css is only required when part css is different. This should only be when (a) host type changes, (b) element part attribute is different, (c) ::theme changes in ancestor tree.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.