Skip to content

Manipulation: Deprecate jQuery.UNSAFE_restoreLegacyHtmlPrefilter #518

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 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/jquery/manipulation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { migratePatchFunc, migrateWarn } from "../main.js";
import { migratePatchAndWarnFunc, migratePatchFunc, migrateWarn } from "../main.js";
import "../disablePatches.js";

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

migratePatchFunc( jQuery, "htmlPrefilter", function( html ) {
warnIfChanged( html );
Expand Down
11 changes: 7 additions & 4 deletions test/unit/jquery/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ QUnit.test( "Improperly closed elements", function( assert ) {
} );

QUnit.test( "jQuery.UNSAFE_restoreLegacyHtmlPrefilter (deprecated)", function( assert ) {
assert.expect( 5 );
assert.expect( 7 );

jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
expectWarning( assert, "jQuery.UNSAFE_restoreLegacyHtmlPrefilter()", 1, function() {
jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
} );

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

assert.equal( warns.length, 1, "Proper warning length" );
assert.ok( warns[ 0 ].indexOf( "HTML tags" ) >= 0, warns[ 0 ] );
assert.equal( warns.length, 2, "Proper warning length" );
assert.ok( warns[ 0 ].indexOf( "jQuery.UNSAFE_restoreLegacyHtmlPrefilter" ) >= 0, warns[ 0 ] );
assert.ok( warns[ 1 ].indexOf( "HTML tags" ) >= 0, warns[ 1 ] );
} );