Skip to content

Commit 140119a

Browse files
authored
Manipulation: Deprecate jQuery.UNSAFE_restoreLegacyHtmlPrefilter
This is unusual as it's not the Core API but we support this patch via a more generic API now: ``` jQuery.migrateEnablePatches( "self-closed-tags" ) ``` Fixes gh-474 Closes gh-518
1 parent 7a2e492 commit 140119a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/jquery/manipulation.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { migratePatchFunc, migrateWarn } from "../main.js";
1+
import { migratePatchAndWarnFunc, migratePatchFunc, migrateWarn } from "../main.js";
22
import "../disablePatches.js";
33

44
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
@@ -19,9 +19,11 @@ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\
1919
* Deprecated, please use `jQuery.migrateDisablePatches( "self-closed-tags" )` instead.
2020
* @deprecated
2121
*/
22-
jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() {
22+
migratePatchAndWarnFunc( jQuery, "UNSAFE_restoreLegacyHtmlPrefilter", function() {
2323
jQuery.migrateEnablePatches( "self-closed-tags" );
24-
};
24+
}, "legacy-self-closed-tags",
25+
"jQuery.UNSAFE_restoreLegacyHtmlPrefilter deprecated; use " +
26+
"`jQuery.migrateEnablePatches( \"self-closed-tags\" )`" );
2527

2628
migratePatchFunc( jQuery, "htmlPrefilter", function( html ) {
2729
warnIfChanged( html );

test/unit/jquery/manipulation.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ QUnit.test( "Improperly closed elements", function( assert ) {
4141
} );
4242

4343
QUnit.test( "jQuery.UNSAFE_restoreLegacyHtmlPrefilter (deprecated)", function( assert ) {
44-
assert.expect( 5 );
44+
assert.expect( 7 );
4545

46-
jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
46+
expectWarning( assert, "jQuery.UNSAFE_restoreLegacyHtmlPrefilter()", 1, function() {
47+
jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
48+
} );
4749

4850
var warns = jQuery.migrateWarnings,
4951
elem = jQuery( "<div/><span/>" ),
@@ -55,6 +57,7 @@ QUnit.test( "jQuery.UNSAFE_restoreLegacyHtmlPrefilter (deprecated)", function( a
5557
assert.strictEqual( firstNodeName, "div", "Proper first element" );
5658
assert.strictEqual( secondNodeName, "span", "Proper second element" );
5759

58-
assert.equal( warns.length, 1, "Proper warning length" );
59-
assert.ok( warns[ 0 ].indexOf( "HTML tags" ) >= 0, warns[ 0 ] );
60+
assert.equal( warns.length, 2, "Proper warning length" );
61+
assert.ok( warns[ 0 ].indexOf( "jQuery.UNSAFE_restoreLegacyHtmlPrefilter" ) >= 0, warns[ 0 ] );
62+
assert.ok( warns[ 1 ].indexOf( "HTML tags" ) >= 0, warns[ 1 ] );
6063
} );

0 commit comments

Comments
 (0)