Skip to content

Commit 18618af

Browse files
committed
CSS: Warn and fill access to jQuery.cssProps
Fixes jquery#283
1 parent d86d4e1 commit 18618af

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/.eslintrc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
},
1212
"globals": {
1313
"window": true,
14+
"Proxy": true,
15+
"Reflect": true,
1416

1517
"define": true,
1618
"module": true,

src/css.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@ jQuery.swap = function( elem, options, callback, args ) {
4242

4343
return ret;
4444
};
45+
46+
if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) {
47+
48+
jQuery.cssProps = new Proxy( jQuery.cssProps || {}, {
49+
set: function() {
50+
migrateWarn( "JQMIGRATE: jQuery.cssProps is deprecated" );
51+
return Reflect.set.apply( this, arguments );
52+
}
53+
} );
54+
}

test/css.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ QUnit.test( "jQuery.swap()", function( assert ) {
2525
} );
2626

2727
} );
28+
29+
QUnit[ ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) ? "test" : "skip" ]
30+
( "jQuery.cssProps", function( assert ) {
31+
assert.expect( 2 );
32+
33+
expectWarning( assert, "Write to cssProps", function() {
34+
jQuery.cssProps.devoHat = "awesomeHat";
35+
} );
36+
37+
expectNoWarning( assert, "Read from cssProps", function() {
38+
jQuery.cssProps.devoHat;
39+
jQuery.cssProps.unknownProp;
40+
} );
41+
42+
delete jQuery.cssProps.devoHat;
43+
} );

warnings.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,9 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58
235235
**Cause:** This public but never-documented method has been deprecated as of jQuery 3.2.0.
236236

237237
**Solution:** Replace calls such as `jQuery.nodeName( elem, "div" )` with a test such as `elem.nodeName.toLowerCase() === "div"`.
238+
239+
### JQMIGRATE: jQuery.cssProps is deprecated
240+
241+
**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.
242+
243+
**Solution:** Remove any uses of `jQuery.cssProps` in application code.

0 commit comments

Comments
 (0)