Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit ebe29b7

Browse files
v1.8.0
1 parent 84a5b81 commit ebe29b7

File tree

5 files changed

+447
-382
lines changed

5 files changed

+447
-382
lines changed

angular.js

Lines changed: 98 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @license AngularJS v1.7.9
3-
* (c) 2010-2018 Google, Inc. http://angularjs.org
2+
* @license AngularJS v1.8.0
3+
* (c) 2010-2020 Google, Inc. http://angularjs.org
44
* License: MIT
55
*/
66
(function(window) {'use strict';
@@ -37,7 +37,7 @@ var minErrConfig = {
3737
* non-positive or non-numeric value, removes the max depth limit.
3838
* Default: 5
3939
*
40-
* * `urlErrorParamsEnabled` **{Boolean}** - Specifies wether the generated error url will
40+
* * `urlErrorParamsEnabled` **{Boolean}** - Specifies whether the generated error url will
4141
* contain the parameters of the thrown error. Disabling the parameters can be useful if the
4242
* generated error url is very long.
4343
*
@@ -87,7 +87,7 @@ function isValidObjectMaxDepth(maxDepth) {
8787
* Since data will be parsed statically during a build step, some restrictions
8888
* are applied with respect to how minErr instances are created and called.
8989
* Instances should have names of the form namespaceMinErr for a minErr created
90-
* using minErr('namespace') . Error codes, namespaces and template strings
90+
* using minErr('namespace'). Error codes, namespaces and template strings
9191
* should all be static strings, not variables or general expressions.
9292
*
9393
* @param {string} module The namespace to use for the new minErr instance.
@@ -99,7 +99,7 @@ function isValidObjectMaxDepth(maxDepth) {
9999
function minErr(module, ErrorConstructor) {
100100
ErrorConstructor = ErrorConstructor || Error;
101101

102-
var url = 'https://errors.angularjs.org/1.7.9/';
102+
var url = 'https://errors.angularjs.org/1.8.0/';
103103
var regex = url.replace('.', '\\.') + '[\\s\\S]*';
104104
var errRegExp = new RegExp(regex, 'g');
105105

@@ -232,6 +232,7 @@ function minErr(module, ErrorConstructor) {
232232
hasOwnProperty,
233233
createMap,
234234
stringify,
235+
UNSAFE_restoreLegacyJqLiteXHTMLReplacement,
235236

236237
NODE_TYPE_ELEMENT,
237238
NODE_TYPE_ATTRIBUTE,
@@ -959,8 +960,8 @@ function arrayRemove(array, value) {
959960
* - [`MediaStream`](https://developer.mozilla.org/docs/Web/API/MediaStream)
960961
* - [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)
961962
* - [`WeakMap`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
962-
* - ['getter'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get)/
963-
* [`setter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set)`
963+
* - [`getter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get)/
964+
* [`setter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set)
964965
*
965966
* @param {*} source The source that will be used to make a copy. Can be any type, including
966967
* primitives, `null`, and `undefined`.
@@ -2088,6 +2089,26 @@ function bindJQuery() {
20882089
bindJQueryFired = true;
20892090
}
20902091

2092+
/**
2093+
* @ngdoc function
2094+
* @name angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement
2095+
* @module ng
2096+
* @kind function
2097+
*
2098+
* @description
2099+
* Restores the pre-1.8 behavior of jqLite that turns XHTML-like strings like
2100+
* `<div /><span />` to `<div></div><span></span>` instead of `<div><span></span></div>`.
2101+
* The new behavior is a security fix. Thus, if you need to call this function, please try to adjust
2102+
* your code for this change and remove your use of this function as soon as possible.
2103+
2104+
* Note that this only patches jqLite. If you use jQuery 3.5.0 or newer, please read the
2105+
* [jQuery 3.5 upgrade guide](https://jquery.com/upgrade-guide/3.5/) for more details
2106+
* about the workarounds.
2107+
*/
2108+
function UNSAFE_restoreLegacyJqLiteXHTMLReplacement() {
2109+
JQLite.legacyXHTMLReplacement = true;
2110+
}
2111+
20912112
/**
20922113
* throw error if the argument is falsy.
20932114
*/
@@ -2807,11 +2828,11 @@ function toDebugString(obj, maxDepth) {
28072828
var version = {
28082829
// These placeholder strings will be replaced by grunt's `build` task.
28092830
// They need to be double- or single-quoted.
2810-
full: '1.7.9',
2831+
full: '1.8.0',
28112832
major: 1,
2812-
minor: 7,
2813-
dot: 9,
2814-
codeName: 'pollution-eradication'
2833+
minor: 8,
2834+
dot: 0,
2835+
codeName: 'nested-vaccination'
28152836
};
28162837

28172838

@@ -2844,6 +2865,7 @@ function publishExternalAPI(angular) {
28442865
'callbacks': {$$counter: 0},
28452866
'getTestability': getTestability,
28462867
'reloadWithDebugInfo': reloadWithDebugInfo,
2868+
'UNSAFE_restoreLegacyJqLiteXHTMLReplacement': UNSAFE_restoreLegacyJqLiteXHTMLReplacement,
28472869
'$$minErr': minErr,
28482870
'$$csp': csp,
28492871
'$$encodeUriSegment': encodeUriSegment,
@@ -2961,7 +2983,7 @@ function publishExternalAPI(angular) {
29612983
});
29622984
}
29632985
])
2964-
.info({ angularVersion: '1.7.9' });
2986+
.info({ angularVersion: '1.8.0' });
29652987
}
29662988

29672989
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -3054,6 +3076,16 @@ function publishExternalAPI(angular) {
30543076
* - [`val()`](http://api.jquery.com/val/)
30553077
* - [`wrap()`](http://api.jquery.com/wrap/)
30563078
*
3079+
* jqLite also provides a method restoring pre-1.8 insecure treatment of XHTML-like tags.
3080+
* This legacy behavior turns input like `<div /><span />` to `<div></div><span></span>`
3081+
* instead of `<div><span></span></div>` like version 1.8 & newer do. To restore it, invoke:
3082+
* ```js
3083+
* angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement();
3084+
* ```
3085+
* Note that this only patches jqLite. If you use jQuery 3.5.0 or newer, please read the
3086+
* [jQuery 3.5 upgrade guide](https://jquery.com/upgrade-guide/3.5/) for more details
3087+
* about the workarounds.
3088+
*
30573089
* ## jQuery/jqLite Extras
30583090
* AngularJS also provides the following additional methods and events to both jQuery and jqLite:
30593091
*
@@ -3133,20 +3165,36 @@ var HTML_REGEXP = /<|&#?\w+;/;
31333165
var TAG_NAME_REGEXP = /<([\w:-]+)/;
31343166
var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi;
31353167

3168+
// Table parts need to be wrapped with `<table>` or they're
3169+
// stripped to their contents when put in a div.
3170+
// XHTML parsers do not magically insert elements in the
3171+
// same way that tag soup parsers do, so we cannot shorten
3172+
// this by omitting <tbody> or other required elements.
31363173
var wrapMap = {
3137-
'option': [1, '<select multiple="multiple">', '</select>'],
3138-
3139-
'thead': [1, '<table>', '</table>'],
3140-
'col': [2, '<table><colgroup>', '</colgroup></table>'],
3141-
'tr': [2, '<table><tbody>', '</tbody></table>'],
3142-
'td': [3, '<table><tbody><tr>', '</tr></tbody></table>'],
3143-
'_default': [0, '', '']
3174+
thead: ['table'],
3175+
col: ['colgroup', 'table'],
3176+
tr: ['tbody', 'table'],
3177+
td: ['tr', 'tbody', 'table']
31443178
};
31453179

3146-
wrapMap.optgroup = wrapMap.option;
31473180
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
31483181
wrapMap.th = wrapMap.td;
31493182

3183+
// Support: IE <10 only
3184+
// IE 9 requires an option wrapper & it needs to have the whole table structure
3185+
// set up in advance; assigning `"<td></td>"` to `tr.innerHTML` doesn't work, etc.
3186+
var wrapMapIE9 = {
3187+
option: [1, '<select multiple="multiple">', '</select>'],
3188+
_default: [0, '', '']
3189+
};
3190+
3191+
for (var key in wrapMap) {
3192+
var wrapMapValueClosing = wrapMap[key];
3193+
var wrapMapValue = wrapMapValueClosing.slice().reverse();
3194+
wrapMapIE9[key] = [wrapMapValue.length, '<' + wrapMapValue.join('><') + '>', '</' + wrapMapValueClosing.join('></') + '>'];
3195+
}
3196+
3197+
wrapMapIE9.optgroup = wrapMapIE9.option;
31503198

31513199
function jqLiteIsTextNode(html) {
31523200
return !HTML_REGEXP.test(html);
@@ -3167,7 +3215,7 @@ function jqLiteHasData(node) {
31673215
}
31683216

31693217
function jqLiteBuildFragment(html, context) {
3170-
var tmp, tag, wrap,
3218+
var tmp, tag, wrap, finalHtml,
31713219
fragment = context.createDocumentFragment(),
31723220
nodes = [], i;
31733221

@@ -3178,13 +3226,30 @@ function jqLiteBuildFragment(html, context) {
31783226
// Convert html into DOM nodes
31793227
tmp = fragment.appendChild(context.createElement('div'));
31803228
tag = (TAG_NAME_REGEXP.exec(html) || ['', ''])[1].toLowerCase();
3181-
wrap = wrapMap[tag] || wrapMap._default;
3182-
tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, '<$1></$2>') + wrap[2];
3229+
finalHtml = JQLite.legacyXHTMLReplacement ?
3230+
html.replace(XHTML_TAG_REGEXP, '<$1></$2>') :
3231+
html;
31833232

3184-
// Descend through wrappers to the right content
3185-
i = wrap[0];
3186-
while (i--) {
3187-
tmp = tmp.lastChild;
3233+
if (msie < 10) {
3234+
wrap = wrapMapIE9[tag] || wrapMapIE9._default;
3235+
tmp.innerHTML = wrap[1] + finalHtml + wrap[2];
3236+
3237+
// Descend through wrappers to the right content
3238+
i = wrap[0];
3239+
while (i--) {
3240+
tmp = tmp.firstChild;
3241+
}
3242+
} else {
3243+
wrap = wrapMap[tag] || [];
3244+
3245+
// Create wrappers & descend into them
3246+
i = wrap.length;
3247+
while (--i > -1) {
3248+
tmp.appendChild(window.document.createElement(wrap[i]));
3249+
tmp = tmp.firstChild;
3250+
}
3251+
3252+
tmp.innerHTML = finalHtml;
31883253
}
31893254

31903255
nodes = concat(nodes, tmp.childNodes);
@@ -8283,7 +8348,7 @@ function $TemplateCacheProvider() {
82838348
*
82848349
* When the original node and the replace template declare the same directive(s), they will be
82858350
* {@link guide/compiler#double-compilation-and-how-to-avoid-it compiled twice} because the compiler
8286-
* does not deduplicate them. In many cases, this is not noticable, but e.g. {@link ngModel} will
8351+
* does not deduplicate them. In many cases, this is not noticeable, but e.g. {@link ngModel} will
82878352
* attach `$formatters` and `$parsers` twice.
82888353
*
82898354
* See issue [#2573](https://github.com/angular/angular.js/issues/2573).
@@ -33606,7 +33671,7 @@ var ngRefDirective = ['$parse', function($parse) {
3360633671
* For example: `item in items | filter:x as results` will store the fragment of the repeated items as `results`, but only after
3360733672
* the items have been processed through the filter.
3360833673
*
33609-
* Please note that `as [variable name] is not an operator but rather a part of ngRepeat
33674+
* Please note that `as [variable name]` is not an operator but rather a part of ngRepeat
3361033675
* micro-syntax so it can be used only after all filters (and not as operator, inside an expression).
3361133676
*
3361233677
* For example: `item in items | filter : x | orderBy : order | limitTo : limit as results track by item.id` .
@@ -34415,11 +34480,11 @@ var ngHideDirective = ['$animate', function($animate) {
3441534480
var colorSpan = element(by.css('span'));
3441634481

3441734482
it('should check ng-style', function() {
34418-
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');
34483+
expect(colorSpan.getCssValue('color')).toMatch(/rgba\(0, 0, 0, 1\)|rgb\(0, 0, 0\)/);
3441934484
element(by.css('input[value=\'set color\']')).click();
34420-
expect(colorSpan.getCssValue('color')).toBe('rgba(255, 0, 0, 1)');
34485+
expect(colorSpan.getCssValue('color')).toMatch(/rgba\(255, 0, 0, 1\)|rgb\(255, 0, 0\)/);
3442134486
element(by.css('input[value=clear]')).click();
34422-
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');
34487+
expect(colorSpan.getCssValue('color')).toMatch(/rgba\(0, 0, 0, 1\)|rgb\(0, 0, 0\)/);
3442334488
});
3442434489
</file>
3442534490
</example>
@@ -36428,4 +36493,4 @@ $provide.value("$locale", {
3642836493

3642936494
})(window);
3643036495

36431-
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>');
36496+
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend(window.angular.element('<style>').text('@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}'));

0 commit comments

Comments
 (0)