// Sass
[data-UI-component="textfield"] {
& > label:only-of-type,
& > label:first-of-type {}
& > input {}
& > label:last-of-type {}
}
/* css output */
[data-UI-component="textfield"] {}
[data-UI-component="textfield"] > label:only-of-type,
[data-UI-component="textfield"] > label:first-of-type {}
[data-UI-component="textfield"] > input {}
[data-UI-component="textfield"] > label:last-of-type {}
That way, you don’t mess-up your template/html with classitis. I like to reserve the use of classes for js logic (states) and for semantics (SEO, schema.org, …), thus using the `data-x` attribute to create and select components.Sure your component’s html/handlebars/whatever template must be kept in sync with its css, and adding elements could totally mess-up things. But I think that’s okay, since changing a component’s template should require a revisit of its stylesheet. What do you think?