W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2014

[whatwg] Better DOM hooks for polyfilling CSS properties?

From: Brian Blakely <anewpage.media@gmail.com>
Date: Thu, 10 Jul 2014 17:38:47 -0400
Message-ID: <CAJGQg4EuVP1Cp++jkWDZROGu_zLVWh364pSCFVy2ThKb-jKKog@mail.gmail.com>
To: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>
Problem
===

It's difficult to know when an unsupported property was set for any arbitrary
element, and manually sifting through stylesheets isn't very easy.

This makes polyfilling CSS harder than it needs to be.

Strawman
===

The endgoal is to easily get a NodeList containing elements that have a
particular invalid/unsupported property applied.

Suggestion 1: Dictionary
---

Object populated with information about elements that have a rejected CSS
property applied.  It updates continuously to reflect the app's most
current state.

document.rejectedCSSProperties = {
  "<rejectedPropertyName>": <NodeList>,
  ...
  ...
};

This, combined with Object.observe, would allow authors an extensible way to
handle unsupported CSS.

Suggestion 2: Query Method
---

document.getElementsByRejectedProperty('foo-bar');

This is the most direct solution.  Maybe more difficult to implement/maintain
vendorside.  Should return live NodeLists, a la getElementsByClassName.

Suggestion 3: Event
---

document.oncsspropertyrejected = function(event) {
  element.property // "foo-bar"
  event.elements // NodeList
};

Kind of similar semantically to the solution in Suggestion 1, but in a
more traditional format.  I prefer Suggestion 1, as it offers a
centralized "registrar" of rejected properties.
Received on Thursday, 10 July 2014 21:39:31 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:21 UTC