Skip to content

Commit a033906

Browse files
Merge pull request #127 from angular/master
Update upstream
2 parents 53e2ea3 + c68b31c commit a033906

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

docs/content/guide/ie.ngdoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ To ensure your AngularJS application works on IE please consider:
3939
of `placeholder="{{ someExpression }}"`. If using the latter, Internet Explorer will error
4040
on accessing the `nodeValue` on a parentless `TextNode` in Internet Explorer 10 & 11
4141
(see [issue 5025](https://github.com/angular/angular.js/issues/5025)).
42+
5. Using the `disabled` attribute on an element that has
43+
descendant form controls can result in unexpected behavior in Internet Explorer 11.
44+
For example, the value of descendant input elements with `ng-model` will not reflect
45+
the model (or changes to the model), and the value of the `placeholder` attribute will be
46+
inserted as the input's value. Descendant select elements will also be inoperable, as if they
47+
had the `disabled` attribute applied to them, which may not be the intended effect.
48+
To work around this unexpected behavior, 1) avoid using the identifier `disabled` for custom attribute
49+
directives that are on elements with descendant form controls, and 2) avoid using `disabled` as an identifier
50+
for an attribute passed to a custom directive that has descendant form controls.

src/minErr.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ function isValidObjectMaxDepth(maxDepth) {
8282

8383
function minErr(module, ErrorConstructor) {
8484
ErrorConstructor = ErrorConstructor || Error;
85+
86+
var url = 'https://errors.angularjs.org/"NG_VERSION_FULL"/';
87+
var regex = url.replace('.', '\\.') + '[\\s\\S]*';
88+
var errRegExp = new RegExp(regex, 'g');
89+
8590
return function() {
8691
var code = arguments[0],
8792
template = arguments[1],
@@ -91,18 +96,22 @@ function minErr(module, ErrorConstructor) {
9196
}),
9297
paramPrefix, i;
9398

99+
// A minErr message has two parts: the message itself and the url that contains the
100+
// encoded message.
101+
// The message's parameters can contain other error messages which also include error urls.
102+
// To prevent the messages from getting too long, we strip the error urls from the parameters.
103+
94104
message += template.replace(/\{\d+\}/g, function(match) {
95105
var index = +match.slice(1, -1);
96106

97107
if (index < templateArgs.length) {
98-
return templateArgs[index];
108+
return templateArgs[index].replace(errRegExp, '');
99109
}
100110

101111
return match;
102112
});
103113

104-
message += '\nhttp://errors.angularjs.org/"NG_VERSION_FULL"/' +
105-
(module ? module + '/' : '') + code;
114+
message += '\n' + url + (module ? module + '/' : '') + code;
106115

107116
for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
108117
message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);

test/minErrSpec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,18 @@ describe('errors', function() {
164164
expect(testError('acode', 'aproblem', 'a', 'b', 'value with space').message)
165165
.toMatch(/^[\s\S]*\?p0=a&p1=b&p2=value%20with%20space$/);
166166
});
167+
168+
169+
it('should strip error reference urls from the error message parameters', function() {
170+
var firstError = testError('firstcode', 'longer string and so on');
171+
172+
var error = testError('secondcode', 'description {0}, and {1}', 'a', firstError.message);
173+
174+
expect(error.message).toBe('[test:secondcode] description a, and [test:firstcode] longer ' +
175+
'string and so on\n\nhttps://errors.angularjs.org/"NG_VERSION_FULL"/test/' +
176+
'secondcode?p0=a&p1=%5Btest%3Afirstcode%5D%20longer%20string%20and%20so%20on%0Ahttps' +
177+
'%3A%2F%2Ferrors.angularjs.org%2F%22NG_VERSION_FULL%22%2Ftest%2Ffirstcode');
178+
});
179+
167180
});
168181
});

0 commit comments

Comments
 (0)