W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

Showing <dialog> from HTML import

From: Ashley Gullen <ashley@scirra.com>
Date: Wed, 18 Feb 2015 13:18:31 +0000
Message-ID: <CAABs73iNuQJhibiZFt2uJOff+6iVPYCdE0TBX8pt1_N1T=oJzA@mail.gmail.com>
To: "public-webapps@w3.org" <public-webapps@w3.org>
I filed crbug.com/458799 for Chrome recently since showing a <dialog>
defined in a HTML import did not work as I thought it should. I can't
compare to any other browsers since right now AFAIK Chrome is the only
browser shipping both HTML imports and <dialog>. There seemed to be some
confusion from the browser developers over what the spec says ought to
happen.

It sounds like the current spec says that showing a dialog marks the "node
document" of the dialog as being blocked. I would imagine a <dialog> in a
HTML import has the invisible HTML import document as the node document of
the <dialog>. Therefore it never appears on-screen (in the main document)
when you call showModal(), but still throws if you try to open it twice.

It can be worked around with JS: the dialog element can be detached from
its current document and appended to the main document, and then
showModal() works as expected.

I think the spec may need to be altered. I think it's an obvious use case
that a web component may want to show a dialog, and naturally that dialog
will be defined in one of the web component's HTML imports. As it stands
though the dialog will never appear unless the JS hack is used. I can also
foresee that a large codebase making use of lots of dialogs ends up with
loads of dialogs appended to the main document, instead of leaving them in
the components where they came from.

Not sure how this would be specified though - perhaps the dialog should be
attached to the main document in showModal(), then re-inserted where it
came from in close()? Sounds like a bit of a hack in itself...

Ashley
Received on Wednesday, 18 February 2015 13:19:02 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC