|
|
|
|
|
by criswell
2815 days ago
|
|
Totally talking without thinking about it too much here: The classList API makes modifications to the class property very easily. You'd be essentially limited to one identifier in attribute selectors. You can't really select from multiple identifiers with a data attribute without doing like: [data-hover*="foo"]
which would search for "foo" anywhere in the attribute, which could mean incorrect substring matches.Chaining attribute selectors would be rough too: [data-hover*="foo"][data-hover*="bar"] {}
vs .foo.bar {}
|
|
So does the dataset interface for custom data attributes: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement...
> You'd be essentially limited to one identifier in attribute selectors. You can't really select from multiple identifiers with a data attribute…
That's just not true, there's an attribute selector that targets strings in a whitespace separated list: [attr~=value], so you could think of .demo as being a shorthand for [class~="demo"], or #demo as a shorthand for [id="demo"].
would target a tag like this: But not a tag like this: More info about attribute selectors: https://drafts.csswg.org/selectors-4/#attribute-representati...