3 ms·
I would like to love web components but they are still quite sucky to use (stringy attributes, bleh), especially if it's not your team who produces them. And s
by morbicer 3y ago
I would like to love web components but they are still quite sucky to use (stringy attributes, bleh), especially if it's not your team who produces them.
And some super basic stuff like buttons in forms is still an unsolved problem:
> Form-associated custom elements: being a submit button
https://github.com/WICG/webcomponents/issues/814 https://github.com/WICG/webcomponents/issues/814
opened 4 years ago and representatives of major browsers still don't have an answer
- mdhb 3y agoThat form issue is actually resolved with full cross browser support already https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals https://developer.mozilla.org/en-US/docs/Web/API/ElementInte... Also you don’t need to pass objects as HTML attributes, I think people pick that up coming from React but the browser lets you pass around objects between components just fine by using properties
- morbicer 3y agoCan you provide me with an example please? I've seen the ElementInternals api but still don't understand how it should help with the case of being able to submit the form by hitting enter in one of the inputs (which is standard html behavior). I wasn't able to find working example anywhere and all the discussions around the issue are still open which leads me to an assumption that this is in fact, still unsolved. https://lit.dev/playground/#project=W3sibmFtZSI6InNpbXBsZS1ncmVldGluZy50cyIsImNvbnRlbnQiOiJpbXBvcnQge2h0bWwsIGNzcywgTGl0RWxlbWVudH0gZnJvbSAnbGl0JztcbmltcG9ydCB7Y3VzdG9tRWxlbWVudCwgcHJvcGVydHl9IGZyb20gJ2xpdC9kZWNvcmF0b3JzLmpzJztcblxuQGN1c3RvbUVsZW1lbnQoJ215LWJ1dHRvbicpXG5leHBvcnQgY2xhc3MgU2ltcGxlR3JlZXRpbmcgZXh0ZW5kcyBMaXRFbGVtZW50IHtcbiAgc3RhdGljIGZvcm1Bc3NvY2lhdGVkID0gdHJ1ZTtcblxuICBAcHJvcGVydHkoKVxuICBuYW1lID0gJ2Zvbyc7XG4gIFxuICBjb25zdHJ1Y3RvcigpIHtcbiAgICBzdXBlcigpO1xuICAgIHRoaXMuYXR0YWNoSW50ZXJuYWxzKCk7XG4gIH1cblxuICByZW5kZXIoKSB7XG4gICAgcmV0dXJuIGh0bWxgPGJ1dHRvbiB0eXBlPVwic3V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