Contact email
yo...@yoav.ws / ywe...@akamai.com
Spec
Relevant spec changes:
https://github.com/whatwg/dom/pull/103
https://github.com/whatwg/dom/pull/107
https://github.com/whatwg/html/pull/340
Summary
We are lacking a way to feature detect features where an attribute can receive a set of predefined keywords. In such features, there's no way to detect support for a certain keyword, as keywords are added over time.
Recent changes to DOMTokenList enable to detect keyword support in a backward compatible way by adding them using the `add()` method, and observing the return value.
Motivation
Lack of feature detection capabilities leads to UA string detection, anarchy and mayhem. This change would enable us to incrementally add keyword based syntax while having a reliable feature detection mechanism for supported keywords.
Compatibility Risk
Low.
The feature detection itself is backwards compatible, since currently `add()` returns undefined, which is falsy. Also, `relList` itself is already shipped in Firefox, so there's little risk that introducing it would cause compat issues.
Ongoing technical constraints
None.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
crbug.com/557597
Link to entry on the feature dashboard
https://www.chromestatus.com/feature/4663631736209408
Requesting approval to ship?
Yes.
If preferable, I can postpone exposing `relList` until <link rel=preload> (which is the main use-case for feature detection on <link rel>) is shipped.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Non-owner's LGTM. I'd like to see this implemented for `iframe@sandbox`, as it suffers from the same fate as `link@rel`. In particular, implementing this will allow Google's anti-malvertising team to feature-detect support for `allow-popups-to-escape-sandbox` rather than whitelisting particular user agents, potentially increasing the number of ads they can lock inside a sandbox.Do you plan on tackling the `sandbox` implementation as well as `rel`?
I must be dense. So we're suggesting a token list that allows a range of values to be set, and only these values, and claim that trying to set a value and inspecting whether or not we can set it is a simple mechanism for detecting whether it is allowed or not (apparently setting the value has no semantic effect - or at least none that's visible in the PRs I read).Why doesn't the attribute simply list the acceptable values?
I strongly support this proposal. So ridiculously simple. :)Hm, looks like you are only implementing it for <link> and <iframe>, but the linked issue discusses the general case. Can you file an issue for those two specific cases instead and update the entry?I think every implemented instance of DOMTokenList should follow this -Since, seemingly, there are not a lot of instances, perhaps support this in all of them (and then keep that issue :))?
So will classList.add("foo") return true?
Non-owner's LGTM. I'd like to see this implemented for `iframe@sandbox`, as it suffers from the same fate as `link@rel`. In particular, implementing this will allow Google's anti-malvertising team to feature-detect support for `allow-popups-to-escape-sandbox` rather than whitelisting particular user agents, potentially increasing the number of ads they can lock inside a sandbox.
--
I'm a little confused about the proposed scope of this Intent. Is it to return a boolean from all DOMTokenList objects? Or just some of them?
Hmm but then how can websites rely on this? If we don't support validation for a certain property we will return true just like for a value that we know we support. How can website tell the difference?
-Christian
Can you show an example of what code you expect developers to write here to support browsers with and without this API (maybe this needs an explainer or blog post or something)? In particular, you'd want clients to feature-detect this API by treating 'false' and 'undefined' differently, right?Rick
On 11/20/2015 12:52 AM, Yoav Weiss wrote:
On Thu, Nov 19, 2015 at 10:34 PM, Chris Harrelson <chri...@chromium.org <mailto:chri...@chromium.org>> wrote:
I'm a little confused about the proposed scope of this Intent. Is it to return a boolean from all DOMTokenList objects? Or just some of
The intent is to return a boolean for the `add()` method of all DOMTokenList objects. That boolean would be true for all these objects where
validation is not relevant (e.g. classList) or not yet implemented. Once that's in place, specific objects (e.g. HTMLLinkElement's relList and
HTMLIFrameElement's sandbox) can add their own validation logic, with their specific supported keywords.
So this possibly breaks feature usage on browsers which support, say rel=prefetch, but don't have DOMTokenList API updated.
!!tokenList.add("foo") is false when add() returns void, but true when add() returns bool as per the change.
Doesn't sound too good.
I'm fine with that. Spec PR at https://github.com/whatwg/dom/pull/114
Hi Yoav,Are you requesting approval to ship this new approach?
Will you include the merge of DOMSettableTokenList into DOMTokenList in this work? It's not strictly related, but the change happened only because of this discussion, and it would be nice to find out if merging them will create a mess in Blink.
--