You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if this is common practise or not but some of our developers ended up creating .grid__item without a .grid or incorrect nesting. I came up with an idea for a system for catching these through a test stylesheet along the lines of:
/* grid__item should always be within a grid */
.grid__item {
outline: 5px solid red;
}
.grid > .grid__item {
outline: none;
}
/* grid should only have grid__item as children */
.grid > :not(.grid__item) {
outline: 5px solid red;
}
I am pretty sure this idea can be extended to other rules to allow developers to visually validate markup. It helped me catch a bunch of errors, especially when markup is being dynamically generated, nested or refactored.
What do you think?
The text was updated successfully, but these errors were encountered:
@unwiredbrain yeah this should not make it's way into production for obvious reasons lest your users see red lines.
Building on the general idea, if you wanted, you could styles such as :after { content:'fail', display: 'none'; } and then write a JS stub. The JS stub could notify you via console.log or even send HTTP requests to example.com/css-errors so you can automatically collect CSS bugs in the wild. That would be pretty sweet actually. Not proposing that for CSS Wizardry, but more of a cool trick for automated CSS testing.
I am not sure if this is common practise or not but some of our developers ended up creating
.grid__item
without a.grid
or incorrect nesting. I came up with an idea for a system for catching these through a test stylesheet along the lines of:I am pretty sure this idea can be extended to other rules to allow developers to visually validate markup. It helped me catch a bunch of errors, especially when markup is being dynamically generated, nested or refactored.
What do you think?
The text was updated successfully, but these errors were encountered: