whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.03k stars 2.62k forks source link

Expose both requested and actual preload state #1932

Open foolip opened 7 years ago

foolip commented 7 years ago

The preload IDL attribute is defined to reflect the content attribute. However, preload="auto" or even preload="metadata" isn't appropriate on all platforms, and Chromium sometimes returns "none" regardless of the content attribute's value, see HTMLMediaElement::preloadType() which is used for the preload IDL attribute as well.

In order to expose both the content attribute's state and what will actually be used, I suggest allowing preload to return the real state and adding defaultPreload to merely reflect the content attribute, similar to defaultMuted.

I argued elsewhere that we need an "effective preload" state, and by letting preload return it we could spec Treat preload="none" as preload="metadata" when load() is called quite easily.

@mounirlamouri

mounirlamouri commented 7 years ago

Can we first spec the preload IDL attribute to return the effective preload state and only add deafultPreload if needed? Basically, it would make preload behave like an enum attribute for which the default value and the allowed values depend on the implementation.

mounirlamouri commented 7 years ago

/CC @cpearce @jernoble

I wrote this simple test page that shows how the preload IDL attribute behaves: https://mounirlamouri.github.io/sandbox/preload/api-exposure.html

As far as I can see:

UA seems to have very different behaviour. I think it would unlikely break websites to change the spec to ask preload to expose the effective preload type but because it would not affect Blink, I might be biased :).

@cpearce and @jernoble, WDYT?

foolip commented 7 years ago

I've tested https://mounirlamouri.github.io/sandbox/preload/api-exposure.html on Edge and it says:

mounirlamouri commented 7 years ago

That's interesting. They seem to have the same behaviour as Blink then.

foolip commented 7 years ago

Except for the default value, yes, and these tests don't reveal if there are any cases in which it's not merely reflecting the content attribute.

mounirlamouri commented 7 years ago

My goal here is to first decide whether we should change preload to return the effective preload type then decide whether reflecting the parsed preload content attribute makes sense. My gut instinct says that it probably wouldn't but I think these two questions can be solved after each other especially because if we don't reflect the effective preload type, preload should be a straightforward enum content attribute reflection.

domenic commented 5 years ago

I know this is an old bug and probably not high priority for the parties involved anymore, but I'll note that we generally want to have reflected IDL attributes for all content attributes. This is necessary for some frameworks that only support properties (IDL attributes) and not (content) attributes, such as React.

So, I think defaultPreload that straightforwardly reflects is a good idea, if someone wants to prioritize it.