Skip to content

Update upstream #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/content/guide/ie.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ To ensure your AngularJS application works on IE please consider:
of `placeholder="{{ someExpression }}"`. If using the latter, Internet Explorer will error
on accessing the `nodeValue` on a parentless `TextNode` in Internet Explorer 10 & 11
(see [issue 5025](https://github.com/angular/angular.js/issues/5025)).
5. Using the `disabled` attribute on an element that has
descendant form controls can result in unexpected behavior in Internet Explorer 11.
For example, the value of descendant input elements with `ng-model` will not reflect
the model (or changes to the model), and the value of the `placeholder` attribute will be
inserted as the input's value. Descendant select elements will also be inoperable, as if they
had the `disabled` attribute applied to them, which may not be the intended effect.
To work around this unexpected behavior, 1) avoid using the identifier `disabled` for custom attribute
directives that are on elements with descendant form controls, and 2) avoid using `disabled` as an identifier
for an attribute passed to a custom directive that has descendant form controls.
15 changes: 12 additions & 3 deletions src/minErr.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ function isValidObjectMaxDepth(maxDepth) {

function minErr(module, ErrorConstructor) {
ErrorConstructor = ErrorConstructor || Error;

var url = 'https://errors.angularjs.org/"NG_VERSION_FULL"/';
var regex = url.replace('.', '\\.') + '[\\s\\S]*';
var errRegExp = new RegExp(regex, 'g');

return function() {
var code = arguments[0],
template = arguments[1],
Expand All @@ -91,18 +96,22 @@ function minErr(module, ErrorConstructor) {
}),
paramPrefix, i;

// A minErr message has two parts: the message itself and the url that contains the
// encoded message.
// The message's parameters can contain other error messages which also include error urls.
// To prevent the messages from getting too long, we strip the error urls from the parameters.

message += template.replace(/\{\d+\}/g, function(match) {
var index = +match.slice(1, -1);

if (index < templateArgs.length) {
return templateArgs[index];
return templateArgs[index].replace(errRegExp, '');
}

return match;
});

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

for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);
Expand Down
13 changes: 13 additions & 0 deletions test/minErrSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,18 @@ describe('errors', function() {
expect(testError('acode', 'aproblem', 'a', 'b', 'value with space').message)
.toMatch(/^[\s\S]*\?p0=a&p1=b&p2=value%20with%20space$/);
});


it('should strip error reference urls from the error message parameters', function() {
var firstError = testError('firstcode', 'longer string and so on');

var error = testError('secondcode', 'description {0}, and {1}', 'a', firstError.message);

expect(error.message).toBe('[test:secondcode] description a, and [test:firstcode] longer ' +
'string and so on\n\nhttps://errors.angularjs.org/"NG_VERSION_FULL"/test/' +
'secondcode?p0=a&p1=%5Btest%3Afirstcode%5D%20longer%20string%20and%20so%20on%0Ahttps' +
'%3A%2F%2Ferrors.angularjs.org%2F%22NG_VERSION_FULL%22%2Ftest%2Ffirstcode');
});

});
});