What does HackerNews think of dialog-polyfill?

Polyfill for the HTML dialog element

Language: JavaScript

#3 in HTML
> - Z-index has no effect in the top-layer. No need to compete for a higher z-index.

This is the kind of boring feature that can end up saving huge amounts of developer time. Z-indexing in CSS is kind of annoying and I've seen projects just detach dialogs from their normal position in the DOM entirely to get around stacking errors before.

----

Minor question:

> - There is only one `top-layer` but it can have many children. Last opened === current element on top.

Is this true? The spec says:

> The top layer is an ordered set of elements, rendered in the order they appear in the set. The last element in the set is rendered last, and thus appears on top.

I'm still playing around with `dialog` elements, so you may well be right, I'm just having trouble finding the actual spec rules about what happens when there are multiple dialogs and they're being simultaneously manipulated.

----

> - Not supported in Safari <= 15.3

Worth noting that there is a polyfill (https://github.com/GoogleChrome/dialog-polyfill), but that the polyfill comes with some fairly large limitations, specifically that they don't advise dialogs be used as children of elements with their own stacking context.

This is reasonable, but also... my first thought when I originally ran into `dialog` was "finally I can stop worrying about which of my elements create new stacking contexts!" -- so it does decrease the usefulness quite a bit.

This does not make sense. Of course new functionality won't work on old browsers.

is easy to polyfill well: https://github.com/GoogleChrome/dialog-polyfill

The [1] and [2] elements are also pretty good for menus and dialogs.

Full working example of a modal dialog:

    
      
        What is your favorite color?
        
        Save
      
    

    
      Show dialog
    
The dialog element is fully supported in Chrome/Edge and Firefox nightly, and there's a polyfill[3] for the others.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/di...

[2]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/me...

[3]: https://github.com/GoogleChrome/dialog-polyfill

You can always drop in a polyfill[1], and when browser support picks up, you can remove it from your dependencies. That is what people used to do when they decided to omit jquery in favor of native web APIs a few years back.

[1]: https://github.com/GoogleChrome/dialog-polyfill