CE slots should also support self-closing tags. no-end tags like "img"
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | self_closing_tags-3054882-11.patch | 2.74 KB | pagach |
| #6 | self_closing_tags-3054882-6.patch | 2.39 KB | pagach |
| #3 | self_closing_tags-3054882-3.patch | 2.38 KB | pagach |
| #2 | self_closing_tags-3054882-2.patch | 2.08 KB | pagach |
Comments
Comment #2
pagach commentedAdded new parameter to define if tag should be self-closing.
Comment #3
pagach commentedNew patch that support self-closing tags and default slot name.
Comment #4
fago- What's the use case for the self-closing tag? Img tag? that's not self-closing but has no end tag in html5: https://www.w3schools.com/tags/tag_img.asp - that's not really self-closing, but just no end tag. We could just hard-code the list of tags which have no end-tag and render them without end-tag? Or leave it up the caller to decide?
also see e.g. https://blog.teamtreehouse.com/to-close-or-not-to-close-tags-in-html5
Comment #5
pagach commentedI'm sure there are other use cases for self closing tags, we are after all using "custom elements" so we can make some custom self-closed tag.
Img is not self-closing yes, but if made as self-closing doesn't break the frontend, if closed like it breaks frontend.
Comment #6
pagach commentedHardcoded list of no end tags.
Comment #7
fagoright, so let's make this about end-tags.
For self-closing tags, I'd suggest we open another issue and just auto-improve into
Comment #8
fagoThat's a bit weird. Imo, if it's a no-end tag so it cannot have content. Let's not add $value here and throw a logic exception is a non-empty value is passed for a no-end tag.
Comment #9
pagach commentedYes, but in
setSlot($key, $value, $tag = 'div', $attributes = [])you need to pass a $value.I'd leave it up to the implementation to just pass an empty string.
Comment #10
fagoright, but point is - it's invalid usage if something non-empty is passed. As a good API, we should tell people when they do something which will end up broken and refuse to do so. And having a non-ending tag with content is broken.
Comment #11
pagach commentedAdded logic exception if no-end tag is given content.
Comment #12
fagothx, that seems good now.
Comment #14
fago