Open Jocs opened 6 years ago
Hey there,
short answer is this
If the tag name begins with a class or id, it defaults to a
<div>
.
https://github.com/hyperhype/hyperscript#default-tag-name
The code in this library was directly taken from here, the original virtual-dom library, which uses (used?) hyperscript to represent the DOM.
Snabbdom uses that same syntax for creating elements.
If what you say is correct and an undefined
selector means it is a text node, then this is a bit weird.
If the tag name begins with a class or id, it defaults to a \
.So we should not translate
undefined
to''
? in other words.selector = selector || ''
is not needed?And need tell the user who use this library it is not a valid selector if he pass
undefined
toparse-sel
?
I think undefined
is valid if we keep the premise that no selector means a default div
.
I wouldn't change any code if we don't need to change any behaviour. Don't you think?
Here are the tests related to the default div
: https://github.com/acstll/parse-sel/blob/master/test.js#L8-L12
Hi,
A little confused about the source code:
if the selector is
undefined
, according to snabbdom vnode data structure, it a text node, why add adiv
tagName?