Skip to content
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

Merged
merged 2 commits into from Apr 12, 2017

Conversation

dreamofabear
Copy link

Fixes #8716.

/to @kmh287

if (AMP_CSS_RE.test(cssClass)) {
initialValue.push(cssClass);
continue;
Copy link
Contributor

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)

Copy link
Author

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.
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

@dreamofabear dreamofabear merged commit 71d5cf9 into ampproject:master Apr 12, 2017
@dreamofabear dreamofabear deleted the bind-verify-class branch April 12, 2017 19:49
DarXector pushed a commit to DarXector/amphtml that referenced this pull request Apr 25, 2017
* fix class verification in amp-bind

* kevin's comment
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* fix class verification in amp-bind

* kevin's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants