New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
amp-bind: Fix [class] verification #8717
amp-bind: Fix [class] verification #8717
Conversation
if (AMP_CSS_RE.test(cssClass)) { | ||
initialValue.push(cssClass); | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Save a line by flipping the condition and putting the push inside the if-statement. (The comment makes the inverted condition easily readable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to be more explicit since the lack of the !
was the source of the bug.
it('should verify class bindings in dev mode', () => { | ||
window.AMP_MODE = {development: true}; | ||
createElementWithBinding(`[class]="'foo'" class="foo"`); // No error. | ||
createElementWithBinding(`[class]="'bar'"`); // Error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please make the reason for the error more explicit in the test. Some ways to do this could be adding a comment that the values need to match or changing the second element to have an explicitly incorrect value for class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.
5629c39
to
fa3c8c2
Compare
* fix class verification in amp-bind * kevin's comment
* fix class verification in amp-bind * kevin's comment
Fixes #8716.
/to @kmh287