Skip to content

Core: Use of jQuery attr instead of hasAttribute. (#2141) #2142

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

Merged
merged 1 commit into from
Jul 30, 2018

Conversation

lopezcjf
Copy link
Contributor

Fixes not supported method hasAttribute on IE with enabled compatibility mode

Fixes #2141

@staabm
Copy link
Member

staabm commented Feb 21, 2018

thx for the PR!

how to reproduce the issue you are fixing? which IE version is affected?

@staabm staabm requested a review from Arkni February 21, 2018 08:57
@lopezcjf
Copy link
Contributor Author

Hi,
I reproduced this error by setting up a basic form with 2 required fields and using IE 11 with enabled compatibility mode (Go to settings -> Compatibility View Settings -> Add the website address, in my scenario is localhost)

Open the page
Click on the first field
Then click on the second field

When focusing out from the first field, the error appears.

@lopezcjf
Copy link
Contributor Author

This is my validation setup:

$('.login-form').validate({
    errorElement: 'span', 
    errorClass: 'help-block', 
    focusInvalid: false, 
    rules: {
        UserName: {
            required: true
        },
        Password: {
            required: true
        }
    },
    messages: {
        UserName: {
            required: resources.IngresarUsuario
        },
        Password: {
            required: resources.IngresarPWD
        }
    },
    invalidHandler: function (event, validator) { 
        $('.alert-danger', $('.login-form')).show();
    },
    highlight: function(element) { 
        $(element)
            .closest('.form-group').addClass('has-error'); 
    },
    success: function (label) {
        $(label).closest('.form-group').removeClass('has-error');
        $(label).remove();
    },
    errorPlacement: function (error, element) {
        $(error).insertAfter($(element).closest('.input-icon'));
    }
});

@Arkni
Copy link
Member

Arkni commented Feb 21, 2018

@staabm

how to reproduce the issue you are fixing? which IE version is affected?

hasAttribute is supported as of IE8. And because we still support down to jQuery 1.7.2 which in its own support IE 7, we have to replace all the 4 occurences of hasAttribute with their equivalent in jQuery using .attr().
That's the main reason why I added the bug label to the linked issue.

We definetly should drop older versions of jQuery in the next major release and stick to versions >v1.10.0, >2.2.0 and v3.0.0 or just support the latest stable version (v3.x.y)

@staabm
Copy link
Member

staabm commented Feb 22, 2018

That's the main reason why I added the bug label to the linked issue.

hmm either the linked issue was added after I did the comment or I missed it completely.
thx for the hint.

We definetly should drop older versions of jQuery in the next major release and stick to versions >v1.10.0, >2.2.0 and v3.0.0 or just support the latest stable version (v3.x.y)

big 👍 .

we should gather some information which usefull BC breaks we should target for 2.0.

@Arkni
Copy link
Member

Arkni commented Mar 3, 2018

Hi @lopezcjf,

Sorry for taking so long to review this.

I did some research in order to have a global understanding of this issue and I was wrong suggesting using .attr() to fix this.
I found out that contenteditable is supported as of IE6 and so we can easily replace the check with element.isContentEditable which returns true is the element is editable otherwise it returns false.
This will help us with the case where the element has no contenteditable attribute but it inherits the editable state from its editable parent (contenteditable = "inherit").

So, can you please update this PR to use isContentEditable property instead.

@Arkni
Copy link
Member

Arkni commented Jun 16, 2018

Hi @lopezcjf,

Just a friendly reminder.

Are you still willing to continue this PR? No worries if you don't have time for it, though.

Thanks!

@Arkni Arkni mentioned this pull request Jul 20, 2018
Copy link
Member

@Arkni Arkni left a comment

Choose a reason for hiding this comment

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

Hi @lopezcjf,

I did the changes I requested in my comment #2142 (comment) on your behalf. Don't worry, I kept the attribution intact (the commit is still authored by you).

I'll merge this PR now.

Thansk for your contribution :)

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.

3 participants