You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgrade guide: Use the new Migrate API to enable the self-closed-tags patch
Advise to use the new API:
```js
jQuery.migrateEnablePatches( "self-closed-tags" );
```
instead of the deprecated one:
```js
jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
```
Also, fix some grammar mistakes & typos.
Closesgh-224
Copy file name to clipboardExpand all lines: pages/upgrade-guide/3.5.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,12 @@
6
6
7
7
### A workaround
8
8
9
-
If you want to upgrade to jQuery 3.5.0 or newer and don't have time to deal with breaking changes at the moment and you use jQuery Migrate 3.2.0 or newer, you can revert to the previous behavior by invoking:
9
+
If you want to upgrade to jQuery 3.5.0 or newer and don't have time to deal with breaking changes at the moment, and you use jQuery Migrate 3.4.0 or newer, you can revert to the previous behavior by invoking:
10
10
```js
11
-
jQuery.UNSAFE_restoreLegacyHtmlPrefilter();
11
+
jQuery.migrateEnablePatches( "self-closed-tags");
12
12
```
13
13
14
-
jQuery Migrate 3.3.0 or newer logs warnings for all input that's affected by this change, regardless of whether the `jQuery.UNSAFE_restoreLegacyHtmlPrefilter()` method was called or not. **Note**: if you overwrite `jQuery.htmlPrefilter` manually, you'll lose those warnings!
14
+
As long as this method has been called, jQuery Migrate 3.4.0 or newer logs warnings for all input that's affected by this change. **Note**: if you overwrite `jQuery.htmlPrefilter` manually, you'll lose those warnings!
15
15
16
16
If you don't use jQuery Migrate, don't add it just for this one workaround. Instead, you can revert to the previous behavior by redefining `jQuery.htmlPrefilter` after loading jQuery:
17
17
```js
@@ -21,7 +21,7 @@ jQuery.htmlPrefilter = function( html ) {
21
21
};
22
22
```
23
23
24
-
Note that if you do this, you lose the jQuery 3.5.0 security fix and you have to be more careful with what HTML you pass to jQuery manipulation methods; regular HTML sanitizing will not be enough. Some security libraries have special sanitization settings for jQuery. For example, [DOMPurify](https://github.com/cure53/DOMPurify) has a `SAFE_FOR_JQUERY` flag:
24
+
Note that if you do this, you lose the jQuery 3.5.0 security fix, and you have to be more careful with what HTML you pass to jQuery manipulation methods; regular HTML sanitizing will not be enough. Some security libraries have special sanitization settings for jQuery. For example, [DOMPurify](https://github.com/cure53/DOMPurify/tree/2.0.17#can-i-configure-dompurify) used to support the `SAFE_FOR_JQUERY` flag in versions `2.0.17` or older:
25
25
```js
26
26
var sanitizedHtml =DOMPurify.sanitize( unsafeHtml, { SAFE_FOR_JQUERY:true } );
27
27
elem.html( sanitizedHtml );
@@ -49,7 +49,7 @@ In jQuery 3.5.0, the `jQuery.htmlPrefilter` method always returns its argument u
49
49
50
50
To avoid this, don't use self-closing tags for tags that may have content unless your page runs in XHTML mode. Make sure you're sending a correct mime type: `application/xhtml+xml`; otherwise, your page will really run in HTML mode.
51
51
52
-
If you're writing a library and you want it to work both in HTML & XHTML modes, remember to use self-closing tags for empty elements, i.e. ones that don't have closing tags in HTML. For example, instead of:
52
+
If you're writing a library, and you want it to work both in HTML & XHTML modes, remember to use self-closing tags for empty elements, i.e. ones that don't have closing tags in HTML. For example, instead of:
53
53
```js
54
54
jQuery( "<div/><img/>" );
55
55
```
@@ -62,4 +62,4 @@ One popular input that still works in jQuery 3.5.0 or newer is the one with a si
62
62
```js
63
63
jQuery( "<div class='yellow' />" );
64
64
```
65
-
This is becuse it's XHTML-compliant and in HTML the parser first changes it to just the opening tag: `<div class='yellow'>` but then immediately auto-closes it as it reaches the end of input.
65
+
This is because it's XHTML-compliant and in HTML the parser first changes it to just the opening tag: `<div class='yellow'>` but then immediately auto-closes it as it reaches the end of input.
0 commit comments