What do you expect to happen?
When calling .css('key', 'val !important'), the correct css is added to the element.
What actually happens?
jQuery silently ignores the css value. This can be tested by performing the following:
$('body').css('background', 'hotpink !important');
Using jQuery 3.2.1, but I can see this issue has been around for a while.
Whether or not this should be added to jQuery is another matter for debate, but I think regardless, the parser should return an error, or at least information, if it has failed to parse CSS that has been passed to it. I've just wasted half an hour on a project trying to figure out why my CSS wasn't being added to a dynamically created element, and didn't stop to think that jQuery might just be ignoring the !important part.
What do you expect to happen?
When calling
.css('key', 'val !important'), the correct css is added to the element.What actually happens?
jQuery silently ignores the css value. This can be tested by performing the following:
Using jQuery 3.2.1, but I can see this issue has been around for a while.
Whether or not this should be added to jQuery is another matter for debate, but I think regardless, the parser should return an error, or at least information, if it has failed to parse CSS that has been passed to it. I've just wasted half an hour on a project trying to figure out why my CSS wasn't being added to a dynamically created element, and didn't stop to think that jQuery might just be ignoring the
!importantpart.