Skip to content

Commit

Permalink
CSS: Warn and fill access to jQuery.cssProps
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed Jun 9, 2019
1 parent d86d4e1 commit 18618af
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"globals": {
"window": true,
"Proxy": true,
"Reflect": true,

"define": true,
"module": true,
Expand Down
10 changes: 10 additions & 0 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ jQuery.swap = function( elem, options, callback, args ) {

return ret;
};

if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) {

jQuery.cssProps = new Proxy( jQuery.cssProps || {}, {
set: function() {
migrateWarn( "JQMIGRATE: jQuery.cssProps is deprecated" );
return Reflect.set.apply( this, arguments );
}
} );
}
16 changes: 16 additions & 0 deletions test/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ QUnit.test( "jQuery.swap()", function( assert ) {
} );

} );

QUnit[ ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) ? "test" : "skip" ]
( "jQuery.cssProps", function( assert ) {
assert.expect( 2 );

expectWarning( assert, "Write to cssProps", function() {
jQuery.cssProps.devoHat = "awesomeHat";
} );

expectNoWarning( assert, "Read from cssProps", function() {
jQuery.cssProps.devoHat;
jQuery.cssProps.unknownProp;
} );

delete jQuery.cssProps.devoHat;
} );
6 changes: 6 additions & 0 deletions warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58
**Cause:** This public but never-documented method has been deprecated as of jQuery 3.2.0.

**Solution:** Replace calls such as `jQuery.nodeName( elem, "div" )` with a test such as `elem.nodeName.toLowerCase() === "div"`.

### JQMIGRATE: jQuery.cssProps is deprecated

**Cause:** The `jQuery.cssProps` property is a public but undocumented object that allows CSS properties with one name to be mapped into another name. It was used for legacy browsers like IE8 that used non-standard names. This object is no longer used inside jQuery since all supported browsers now use the standard CSS property names.

**Solution:** Remove any uses of `jQuery.cssProps` in application code.

0 comments on commit 18618af

Please sign in to comment.