Use data-id attribute to select loading message, instead of CSS class…#9248
Conversation
… since that creates a brittle coupling between JS and CSS. - Formalize this rule in the CSS style guide.
|
I completely agree with not using the css .class selector in this scenario; however, I'd like to suggest an alternative solution. It's my understanding that the 'hideLoadingMessage' functionality is only used to hide the loading message in embedded mode. Instead of adding a 'data-id' attribute, I feel like it'd be more clear if we added an attribute such as 'data-hide-for-embedded' ( or a better name ) and use that attribute to determine what we hide in embedded mode. That way we're marking the elements based on the intention of what we intend to happen to them. Also, I don't think that we need to mark the parent of the element that we want removed, and instead we should be able to use |
|
Curious, how does this help with the brittleness? If someone deleted .kibanaLoadingMessage but left the onload function as it was, wouldn't we get in the same crash situation? Or does data-id do something special? |
|
@kobelb I think those are great ideas. I'll update the PR. |
stacey-gammon
left a comment
There was a problem hiding this comment.
Nice. I agree the more specific data tag makes it obvious that it's important and needs to be left in. Otherwise I could see someone updating the class name and the data-id tag simultaneously, just to keep them in sync.
Backports PR #9248 **Commit 1:** Use data-id attribute to select loading message, instead of CSS class since that creates a brittle coupling between JS and CSS. - Formalize this rule in the CSS style guide. * Original sha: d574763 * Authored by CJ Cenizal <cj@cenizal.com> on 2016-11-29T17:28:48Z **Commit 2:** Use uniquely and semantically named data attribute instead of data-id. * Original sha: 0b42628 * Authored by CJ Cenizal <cj@cenizal.com> on 2016-11-29T20:24:54Z
#9271) Backports PR #9248 **Commit 1:** Use data-id attribute to select loading message, instead of CSS class since that creates a brittle coupling between JS and CSS. - Formalize this rule in the CSS style guide. * Original sha: d574763 * Authored by CJ Cenizal <cj@cenizal.com> on 2016-11-29T17:28:48Z **Commit 2:** Use uniquely and semantically named data attribute instead of data-id. * Original sha: 0b42628 * Authored by CJ Cenizal <cj@cenizal.com> on 2016-11-29T20:24:54Z
… since that creates a brittle coupling between JS and CSS.
Also, formalize this rule in the CSS style guide.
This change will help avoid problems like the one solved in #9235.