html icon indicating copy to clipboard operation
html copied to clipboard

"being rendered" requirement around `<object>` loading is pretty odd

Open bzbarsky opened this issue 8 years ago • 4 comments

Per the current HTML spec, an <object> is not loaded if it's not being rendered. And if the "being rendered" state changes, it should discard its data or reload it (depending on whether it stops being rendered or starts again).

So per the letter of the spec, every time an <object>, or any ancestor, gets toggled to display:none and back it should redo the fetch for its data attribute, which seems like a really weird behavior. I'm quite sure Gecko doesn't implement this and it's not needed for web compat; I can't speak for other browsers.

The web compat behavior I'm aware of here is not executing plug-ins for display:none <object>. I can't speak to whether the load happens, by the way; I haven't checked the details in any browsers.

Apart from that, why should "being rendered" affect <object> in any way? It doesn't affect <img> or <audio> or <video>...

bzbarsky avatar May 17 '17 03:05 bzbarsky

IIRC, this comes from Hixie trying to spec the behavior of Gecko. I don't know if Gecko has since changed or if the spec was wrong to begin with. But in any case, I don't see any particular reason to have this like the spec currently requires.

I suppose there should be two separate things here, then: (1) the current algorithm, but run it even for display:none and don't re-run it when "being rendered" changes, and (2) a separate algorithm to invoke and kill plugins, based on "being rendered". Is that closer to what Gecko does?

zcorpan avatar Jun 02 '17 11:06 zcorpan

Depending on when hixie was speccing this, Gecko may well have changed. A long enough time ago, Gecko did the resource loading for <object> from the layout box, not the element...

I'll defer to @qdot on what exactly Gecko does; I don't remember it offhand...

bzbarsky avatar Jun 02 '17 14:06 bzbarsky

It's also really worth changing what other UAs do, of course.

bzbarsky avatar Jun 02 '17 14:06 bzbarsky

Just noticed that Safari now does even this reloading when the position of the <object> element is changed to absolute. https://jsfiddle.net/hx1eautp/ I remember they didn't always do that and I'm not sure it follows the being rendered definition (the element still has a box, even if maybe not the same).

But it seems that as of today only Safari does this reload on being rendered, and not even as per the specs text: in case of display: none, they unload the attached document only when the <object> is rendered again, which is the behavior specced for <embed> https://jsfiddle.net/wuL4y73f/.

I was considering simply opening an issue at WebKit regarding the position stuff, but it might actually be better to fix the specs first to match the majority and adopt the same behavior as <iframe> expose, i.e. no reload based on being rendered.

Kaiido avatar Feb 22 '24 02:02 Kaiido