-
Notifications
You must be signed in to change notification settings - Fork 20
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
Silent error when first argument is jQuery object #23
Comments
The issue is that tagger thinks that jQuery object is an array and doesn't return tagger object but an array. if (input.length) {
return Array.from(input).map(function(input) {
return new tagger(input, options);
});
} |
This also occurs if you initialise using document.querySelectorAll which will return a NodeList even if only a single element exists. Adding this to the top of the function tagger(input, options) will flatten the array if it contains only one element, works for both $() and document.querySelectorAll() if (input.length && input.length === 1) {
input = Array.from(input).pop();
} |
@lucasnetau do you want to create a PR with this fix? |
@jcubic sure I'll make one. I'll also add some documentation around if a single instance is created it will always be returned as an object even if it was provided in a single element array. Single Instance initialised => tagger() returns object |
* Return without creation if an empty NodeList or iterable is passed in * Flatten a NodeList or iterable if it contains a single element * Document the return type of tagger() in the readme to cover the single element in list case Closes jcubic#23
…odeList or iterable is passed in * Flatten a NodeList or iterable if it contains a single element * Document the return type of tagger() in the readme to cover the single element in list case Closes jcubic#23
If you pass jQuery object as first argument component is created but the return object is not tagger object. Which in turn throws different error when you try to invoke a method.
The text was updated successfully, but these errors were encountered: