jqLite.js (angular.js-1.7.9) | : | jqLite.js (angular.js-1.8.0) | ||
---|---|---|---|---|
skipping to change at line 93 | skipping to change at line 93 | |||
* - [`removeClass()`](http://api.jquery.com/removeClass/) - Does not support a function as first argument | * - [`removeClass()`](http://api.jquery.com/removeClass/) - Does not support a function as first argument | |||
* - [`removeData()`](http://api.jquery.com/removeData/) | * - [`removeData()`](http://api.jquery.com/removeData/) | |||
* - [`replaceWith()`](http://api.jquery.com/replaceWith/) | * - [`replaceWith()`](http://api.jquery.com/replaceWith/) | |||
* - [`text()`](http://api.jquery.com/text/) | * - [`text()`](http://api.jquery.com/text/) | |||
* - [`toggleClass()`](http://api.jquery.com/toggleClass/) - Does not support a function as first argument | * - [`toggleClass()`](http://api.jquery.com/toggleClass/) - Does not support a function as first argument | |||
* - [`triggerHandler()`](http://api.jquery.com/triggerHandler/) - Passes a dumm y event object to handlers | * - [`triggerHandler()`](http://api.jquery.com/triggerHandler/) - Passes a dumm y event object to handlers | |||
* - [`unbind()`](http://api.jquery.com/unbind/) (_deprecated_, use [`off()`](ht tp://api.jquery.com/off/)) - Does not support namespaces or event object as para meter | * - [`unbind()`](http://api.jquery.com/unbind/) (_deprecated_, use [`off()`](ht tp://api.jquery.com/off/)) - Does not support namespaces or event object as para meter | |||
* - [`val()`](http://api.jquery.com/val/) | * - [`val()`](http://api.jquery.com/val/) | |||
* - [`wrap()`](http://api.jquery.com/wrap/) | * - [`wrap()`](http://api.jquery.com/wrap/) | |||
* | * | |||
* jqLite also provides a method restoring pre-1.8 insecure treatment of XHTML-l | ||||
ike tags. | ||||
* This legacy behavior turns input like `<div /><span />` to `<div></div><span> | ||||
</span>` | ||||
* instead of `<div><span></span></div>` like version 1.8 & newer do. To restore | ||||
it, invoke: | ||||
* ```js | ||||
* angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement(); | ||||
* ``` | ||||
* Note that this only patches jqLite. If you use jQuery 3.5.0 or newer, please | ||||
read the | ||||
* [jQuery 3.5 upgrade guide](https://jquery.com/upgrade-guide/3.5/) for more de | ||||
tails | ||||
* about the workarounds. | ||||
* | ||||
* ## jQuery/jqLite Extras | * ## jQuery/jqLite Extras | |||
* AngularJS also provides the following additional methods and events to both j Query and jqLite: | * AngularJS also provides the following additional methods and events to both j Query and jqLite: | |||
* | * | |||
* ### Events | * ### Events | |||
* - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event | * - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event | |||
* on all DOM nodes being removed. This can be used to clean up any 3rd part y bindings to the DOM | * on all DOM nodes being removed. This can be used to clean up any 3rd part y bindings to the DOM | |||
* element before it is removed. | * element before it is removed. | |||
* | * | |||
* ### Methods | * ### Methods | |||
* - `controller(name)` - retrieves the controller of the current element or its parent. By default | * - `controller(name)` - retrieves the controller of the current element or its parent. By default | |||
skipping to change at line 171 | skipping to change at line 181 | |||
function kebabToCamel(name) { | function kebabToCamel(name) { | |||
return name | return name | |||
.replace(DASH_LOWERCASE_REGEXP, fnCamelCaseReplace); | .replace(DASH_LOWERCASE_REGEXP, fnCamelCaseReplace); | |||
} | } | |||
var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; | var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/; | |||
var HTML_REGEXP = /<|&#?\w+;/; | var HTML_REGEXP = /<|&#?\w+;/; | |||
var TAG_NAME_REGEXP = /<([\w:-]+)/; | var TAG_NAME_REGEXP = /<([\w:-]+)/; | |||
var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w :-]+)[^>]*)\/>/gi; | var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w :-]+)[^>]*)\/>/gi; | |||
// Table parts need to be wrapped with `<table>` or they're | ||||
// stripped to their contents when put in a div. | ||||
// XHTML parsers do not magically insert elements in the | ||||
// same way that tag soup parsers do, so we cannot shorten | ||||
// this by omitting <tbody> or other required elements. | ||||
var wrapMap = { | var wrapMap = { | |||
'option': [1, '<select multiple="multiple">', '</select>'], | thead: ['table'], | |||
col: ['colgroup', 'table'], | ||||
'thead': [1, '<table>', '</table>'], | tr: ['tbody', 'table'], | |||
'col': [2, '<table><colgroup>', '</colgroup></table>'], | td: ['tr', 'tbody', 'table'] | |||
'tr': [2, '<table><tbody>', '</tbody></table>'], | ||||
'td': [3, '<table><tbody><tr>', '</tr></tbody></table>'], | ||||
'_default': [0, '', ''] | ||||
}; | }; | |||
wrapMap.optgroup = wrapMap.option; | ||||
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.the ad; | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.the ad; | |||
wrapMap.th = wrapMap.td; | wrapMap.th = wrapMap.td; | |||
// Support: IE <10 only | ||||
// IE 9 requires an option wrapper & it needs to have the whole table structure | ||||
// set up in advance; assigning `"<td></td>"` to `tr.innerHTML` doesn't work, et | ||||
c. | ||||
var wrapMapIE9 = { | ||||
option: [1, '<select multiple="multiple">', '</select>'], | ||||
_default: [0, '', ''] | ||||
}; | ||||
for (var key in wrapMap) { | ||||
var wrapMapValueClosing = wrapMap[key]; | ||||
var wrapMapValue = wrapMapValueClosing.slice().reverse(); | ||||
wrapMapIE9[key] = [wrapMapValue.length, '<' + wrapMapValue.join('><') + '>', ' | ||||
</' + wrapMapValueClosing.join('></') + '>']; | ||||
} | ||||
wrapMapIE9.optgroup = wrapMapIE9.option; | ||||
function jqLiteIsTextNode(html) { | function jqLiteIsTextNode(html) { | |||
return !HTML_REGEXP.test(html); | return !HTML_REGEXP.test(html); | |||
} | } | |||
function jqLiteAcceptsData(node) { | function jqLiteAcceptsData(node) { | |||
// The window object can accept data but has no nodeType | // The window object can accept data but has no nodeType | |||
// Otherwise we are only interested in elements (1) and documents (9) | // Otherwise we are only interested in elements (1) and documents (9) | |||
var nodeType = node.nodeType; | var nodeType = node.nodeType; | |||
return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_D OCUMENT; | return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_D OCUMENT; | |||
} | } | |||
function jqLiteHasData(node) { | function jqLiteHasData(node) { | |||
for (var key in jqCache[node.ng339]) { | for (var key in jqCache[node.ng339]) { | |||
return true; | return true; | |||
} | } | |||
return false; | return false; | |||
} | } | |||
function jqLiteBuildFragment(html, context) { | function jqLiteBuildFragment(html, context) { | |||
var tmp, tag, wrap, | var tmp, tag, wrap, finalHtml, | |||
fragment = context.createDocumentFragment(), | fragment = context.createDocumentFragment(), | |||
nodes = [], i; | nodes = [], i; | |||
if (jqLiteIsTextNode(html)) { | if (jqLiteIsTextNode(html)) { | |||
// Convert non-html into a text node | // Convert non-html into a text node | |||
nodes.push(context.createTextNode(html)); | nodes.push(context.createTextNode(html)); | |||
} else { | } else { | |||
// Convert html into DOM nodes | // Convert html into DOM nodes | |||
tmp = fragment.appendChild(context.createElement('div')); | tmp = fragment.appendChild(context.createElement('div')); | |||
tag = (TAG_NAME_REGEXP.exec(html) || ['', ''])[1].toLowerCase(); | tag = (TAG_NAME_REGEXP.exec(html) || ['', ''])[1].toLowerCase(); | |||
wrap = wrapMap[tag] || wrapMap._default; | finalHtml = JQLite.legacyXHTMLReplacement ? | |||
tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, '<$1></$2>') + wrap | html.replace(XHTML_TAG_REGEXP, '<$1></$2>') : | |||
[2]; | html; | |||
if (msie < 10) { | ||||
wrap = wrapMapIE9[tag] || wrapMapIE9._default; | ||||
tmp.innerHTML = wrap[1] + finalHtml + wrap[2]; | ||||
// Descend through wrappers to the right content | ||||
i = wrap[0]; | ||||
while (i--) { | ||||
tmp = tmp.firstChild; | ||||
} | ||||
} else { | ||||
wrap = wrapMap[tag] || []; | ||||
// Create wrappers & descend into them | ||||
i = wrap.length; | ||||
while (--i > -1) { | ||||
tmp.appendChild(window.document.createElement(wrap[i])); | ||||
tmp = tmp.firstChild; | ||||
} | ||||
// Descend through wrappers to the right content | tmp.innerHTML = finalHtml; | |||
i = wrap[0]; | ||||
while (i--) { | ||||
tmp = tmp.lastChild; | ||||
} | } | |||
nodes = concat(nodes, tmp.childNodes); | nodes = concat(nodes, tmp.childNodes); | |||
tmp = fragment.firstChild; | tmp = fragment.firstChild; | |||
tmp.textContent = ''; | tmp.textContent = ''; | |||
} | } | |||
// Remove wrapper from fragment | // Remove wrapper from fragment | |||
fragment.textContent = ''; | fragment.textContent = ''; | |||
End of changes. 8 change blocks. | ||||
16 lines changed or deleted | 66 lines changed or added |