9090 * - [`val()`](http://api.jquery.com/val/)
9191 * - [`wrap()`](http://api.jquery.com/wrap/)
9292 *
93+ * jqLite also provides a method restoring pre-1.8 insecure treatment of XHTML-like tags
94+ * that makes input like `<div /><span />` turned to `<div></div><span></span>` instead of
95+ * `<div><span></span></div>` like version 1.8 & newer do:
96+ * ```js
97+ * angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement();
98+ * ```
99+ * Note that this only patches jqLite. If you use jQuery 3.5.0 or newer, please read
100+ * [jQuery 3.5 upgrade guide](https://jquery.com/upgrade-guide/3.5/) for more details
101+ * about the workarounds.
102+ *
93103 * ## jQuery/jqLite Extras
94104 * AngularJS also provides the following additional methods and events to both jQuery and jqLite:
95105 *
@@ -170,19 +180,23 @@ var TAG_NAME_REGEXP = /<([\w:-]+)/;
170180var XHTML_TAG_REGEXP = / < (? ! a r e a | b r | c o l | e m b e d | h r | i m g | i n p u t | l i n k | m e t a | p a r a m ) ( ( [ \w : - ] + ) [ ^ > ] * ) \/ > / gi;
171181
172182var wrapMap = {
173- 'option' : [ 1 , '<select multiple="multiple">' , '</select>' ] ,
174-
175183 'thead' : [ 1 , '<table>' , '</table>' ] ,
176184 'col' : [ 2 , '<table><colgroup>' , '</colgroup></table>' ] ,
177185 'tr' : [ 2 , '<table><tbody>' , '</tbody></table>' ] ,
178186 'td' : [ 3 , '<table><tbody><tr>' , '</tr></tbody></table>' ] ,
179187 '_default' : [ 0 , '' , '' ]
180188} ;
181189
182- wrapMap . optgroup = wrapMap . option ;
183190wrapMap . tbody = wrapMap . tfoot = wrapMap . colgroup = wrapMap . caption = wrapMap . thead ;
184191wrapMap . th = wrapMap . td ;
185192
193+ // Support: IE <=9 only
194+ // IE <=9 replaces <option> tags with their contents when inserted outside of
195+ // the select element.
196+ if ( msie < 10 ) {
197+ wrapMap . optgroup = wrapMap . option = [ 1 , '<select multiple="multiple">' , '</select>' ] ;
198+ }
199+
186200
187201function jqLiteIsTextNode ( html ) {
188202 return ! HTML_REGEXP . test ( html ) ;
@@ -203,7 +217,7 @@ function jqLiteHasData(node) {
203217}
204218
205219function jqLiteBuildFragment ( html , context ) {
206- var tmp , tag , wrap ,
220+ var tmp , tag , wrap , finalHtml ,
207221 fragment = context . createDocumentFragment ( ) ,
208222 nodes = [ ] , i ;
209223
@@ -215,7 +229,10 @@ function jqLiteBuildFragment(html, context) {
215229 tmp = fragment . appendChild ( context . createElement ( 'div' ) ) ;
216230 tag = ( TAG_NAME_REGEXP . exec ( html ) || [ '' , '' ] ) [ 1 ] . toLowerCase ( ) ;
217231 wrap = wrapMap [ tag ] || wrapMap . _default ;
218- tmp . innerHTML = wrap [ 1 ] + html . replace ( XHTML_TAG_REGEXP , '<$1></$2>' ) + wrap [ 2 ] ;
232+ finalHtml = JQLite . legacyXHTMLReplacement ?
233+ html . replace ( XHTML_TAG_REGEXP , '<$1></$2>' ) :
234+ html ;
235+ tmp . innerHTML = wrap [ 1 ] + finalHtml + wrap [ 2 ] ;
219236
220237 // Descend through wrappers to the right content
221238 i = wrap [ 0 ] ;
0 commit comments