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

Mess with maxlength only if specified #56

Merged
merged 1 commit into from Nov 29, 2013

Conversation

paracycle
Copy link
Contributor

It seems the previous patch was causing problems in Firefox 3.6 since it
was returning -1 for the value of the maxlength attribute if the
attribute was never supplied in the first place.

This patch tries to detect if the maxlength was supplied, and only
proceeds to manipulate it if it is present.

Note: Unfortunately, I had no time to test this change in an actual browser. Please, please, test it in IE8 and Firefox 3.6 before merging. Thanks and sorry for the extra work.

It seems the previous patch was causing problems in Firefox 3.6 since it
was returning -1 for the value of the maxlength attribute if the
attribute was never supplied in the first place.

This patch tries to detect if the maxlength was supplied, and only
proceeds to manipulate it if it is present.
@leejordan
Copy link

If it's useful, I tested in firefox 3.6 and ie8 and it works for both.

elem.removeAttribute("maxLength");
if (elem.hasAttribute("maxLength")) {
maxLength = elem.getAttribute("maxLength") || elem.maxLength;
if (parseInt(maxLength, 10) > 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is parseInt needed here? The > operator should coerce its operands to Number. If it is needed, why is it not needed on line 91?

@jamesallardice
Copy link
Owner

Thanks for this, and apologies for not testing the original PR thoroughly enough. I've added one small comment to the diff. Once that's cleared up I'll get this tested properly and merged as soon as possible.

jamesallardice pushed a commit that referenced this pull request Nov 29, 2013
Mess with maxlength only if specified
@jamesallardice jamesallardice merged commit 18bd6b0 into jamesallardice:master Nov 29, 2013
jamesallardice pushed a commit that referenced this pull request Nov 29, 2013
This reverts commit 18bd6b0, reversing
changes made to 0d99837.

Conflicts:

	lib/main.js
@jamesallardice
Copy link
Owner

I merged this but unfortunately noticed when testing that hasAttribute is only supported in IE8 and above. The polyfill needs to support down to IE6 so hasAttribute is not an appropriate solution. I've reverted the merge and will look into an alternative approach.

@paracycle
Copy link
Contributor Author

Hi @jamesallardice, I am extremely sorry for the poor quality initial pull-request and the rushed second one. I totally missed your comment on the diff and didn't realize that hasAttribute was not supported on < IE8.

Your fix will work fine. However, I have realized that the initial logic in my initial pull-request could have been refined. I'll work on a better refinement that supports IE6 and up as well, and send you another pull-request.

Thanks for all your efforts.

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.

None yet

3 participants