5 ms·
This looks good. Minor gripe: not sure if it's a good idea that the network be an attribute name instead of an attribute value; to this: <comment-box hack
by bambax 10y ago
This looks good.
Minor gripe: not sure if it's a good idea that the network be an attribute name instead of an attribute value; to this:
<comment-box hackernews="11850599" limit="1" class="border"></comment-box>
I would prefer:
<comment-box network="hackernews" items="11850599" limit="1" class="border"></comment-box>
If you have a different attribute name per network, the DTD changes every time you add a network. Not that anyone cares, but still.
- - -
Edit: a previous version of this comment asked why the tag was not self-closing; in fact, custom elements in HTML5 should indeed have a closing tag; see
http://stackoverflow.com/questions/23961178/do-custom-elements-require-a-close-tag http://stackoverflow.com/questions/23961178/do-custom-elemen...
- jffry 10y agoI'm not sure that you can have self-closing custom tags in HTML5. Per [1], ...if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing. The list of element types [2] is fairly short, so I think if you attempted to self-close a custom tag, behavior might depend on how the parser's error recovery treats custom elements. [1] http://w3c.github.io/html/syntax.html#start-tags http://w3c.github.io/html/syntax.html#start-tags [2] http://w3c.github.io/html/syntax.html#writing-html-documents-elements http://w3c.github.io/html/syntax.html#writing-html-documents...
- bambax 10y agoYou're right it seems! I have edited my comment to reflect this. (Why would HTML5 have both self-closing and non-self closing tags though?? It's just a syntax shortcut, they should either take it or leave it, but create a special class of "empty tags" seems crazy to me).
- Navarr 10y agoI think keeping the network as an attribute name would allow it to do multiple networks in one box in the future.
- franciscop 10y agoNot future, you can already do it: https://jsfiddle.net/franciscop/eo5v6ghc/ https://jsfiddle.net/franciscop/eo5v6ghc/
- andrewstuart2 10y agoExcept that the whole promise of XML and DTD is that you can have validated serialization of your objects. If the network is switched to an attribute name with a string value, it can no longer be validated that you've chosen a valid network, unless you use an enumeration (in which case you've still changed the DTD).
- bambax 10y agoYes, if you use an enumeration you do change the DTD each time you add a network, but not the structure of the element. It's not the same error and it doesn't tell you the same thing. It's obviously not very important... I can't seem to be able to put into words why it bothers me so much! ;-)
- franciscop 10y agoThat's an interesting idea, but since we have to manually add each network and then it's automatically parsed from that list, at least on my end it wouldn't make any difference at all. Also one of the main features is that you can mix different networks and different threads per network, so that would be really confusing: what does this mean? <comment-box network="hackernews reddit" items="11850599 11850500 11859454"></comment-box> For the Edit: I searched this thorough, custom elements cannot be self-closing. And the closest thing that I found indicates that, even if they could be self-closing (void elements), then they cannot have anything inside (which is also not what I wanted). See example: https://jsfiddle.net/franciscop/eo5v6ghc/ https://jsfiddle.net/franciscop/eo5v6ghc/
- bambax 10y ago> on my end it wouldn't make any difference at all Sure, but attribute (or tag) names refer the the structure of the document whereas values refer to each special case; structurally (essentially) those two are the same: <comment-box hackernews="1"> <comment-box reddit="4"> but you can't tell because they have different attributes. Okay, so in order to write (current solution): <comment-box hackernews="11850599" reddit="11850500 11859454"></comment-box> you could do: <comment-box network="hackernews" items="11850599"></comment-box> <comment-box network="reddit" items="11850500 11859454"></comment-box> which would work just the same, you just have to group consecutive comment-box into one; or you could even do this: <comment-box sources="hackernews: 11850599; reddit: 11850500 11859454"></comment-box> (inline css style).
- bambax 10y agoThe last example of my previous comment is a little ugly; in "real" XML we would write: <comment-box> <source name="hackernews" items="12"/> <source name="reddit" items="24 27"/> </comment-box> which would be very readable; but since we don't have self-closing tags and we need to use hyphens in tag names, it's probably defensible to try to limit the number of tags and put as much information as possible inside attributes...
- franciscop 10y ago