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

fix(angular): do not launch the directive if autocomplete has a value #138

Merged
merged 1 commit into from
Jan 6, 2017

Conversation

Jerska
Copy link
Member

@Jerska Jerska commented Jan 6, 2017

Closes #136

Summary

As described in #136 , we're bugging out the behavior of the HTML autocomplete attribute.
You can't use autocomplete="off" in the current setup, this PR fixes it.

Result

Checked in test/playground_angular.html.
Attribute mode:

  • autocomplete => our autocomplete triggers
  • autocomplete="" => our autocomplete triggers
  • autocomplete="off" => our autocomplete doesn't trigger and it correctly prevents the browser from autocompleting
  • data-autocomplete => our autocomplete triggers

I've also checked that the class mode of the directive still works.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 88.849% when pulling f96a1ba on fix/angular into be1dc19 on master.

@@ -36,6 +36,7 @@ angular.module('algolia.autocomplete', [])
datasets: '&aaDatasets'
},
link: function(scope, element, attrs) {
if (!element.hasClass('autocomplete') && attrs.autocomplete !== '') return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to check the class ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of the restrict option used here: https://github.com/algolia/autocomplete.js/blob/f96a1bad72212066dab735de08d560cf6122f65b/src/angular/directive.js#L33

 restrict: 'AC', // Only apply on an attribute or class

@vvo
Copy link
Contributor

vvo commented Jan 6, 2017

Are browsers reporting the same value when you set <input autocomplete and try to get the autocomplete attr value?

Could we ensure this quickly on evegreen browsers and IE10+? I know this is hairy to do, a simple jsFiddle with an alert could do it and you launch it from saucelabs or smg else

@Jerska
Copy link
Member Author

Jerska commented Jan 6, 2017

Confirmed in IE9 and Safari 6 (using a simple console.log(JSON.stringify(attrs.autocomplete)); and loading playground_angular.html in browserstack)
As soon as those two were confirmed, I didn't bother checking the rest.

@vvo vvo merged commit 4a305f6 into master Jan 6, 2017
@vvo
Copy link
Contributor

vvo commented Jan 6, 2017

Thanks a lot

@vvo vvo deleted the fix/angular branch January 6, 2017 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular directive name conflicts with autocomplete="off"
4 participants