https://github.com/angular/angular
Revision 879ff08f0eb22a54f6b97399400daee3d95ab822 authored by Keen Yee Liau on 29 July 2020, 20:25:17 UTC, committed by Alex Rickabaugh on 30 July 2020, 22:18:28 UTC
This commit fixes a bug in View Engine whereby the compiler errorneously
thinks that a method of a component has decorator metadata when that
method is one of those in `Object.prototype`, for example `toString`.

This bug is discovered in v10.0.4 of `@angular/language-service` after
the default bundle format was switched from ES5 to ES2015.

ES5 output:
```js
if (propMetadata[propName]) {
    decorators.push.apply(decorators, __spread(propMetadata[propName]));
}
```

ES2015 output:
```js
if (propMetadata[propName]) {
    decorators.push(...propMetadata[propName]);
}
```

The bug was not discovered in ES5 because the polyfill for the spread
operator happily accepts parameters that do not have the `iterable`
symbol:

```js
function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}
```

whereas in es2015 it’ll fail since the iterable symbol is not present in
`propMetadata['toString']` which evaluates to a function.

Fixes https://github.com/angular/vscode-ng-language-service/issues/859

PR Close #38292
1 parent a15d7ac
History
Tip revision: 879ff08f0eb22a54f6b97399400daee3d95ab822 authored by Keen Yee Liau on 29 July 2020, 20:25:17 UTC
fix(compiler): Metadata should not include methods on Object.prototype (#38292)
Tip revision: 879ff08
File Mode Size
.circleci
.devcontainer
.github
.ng-dev
.vscode
.yarn
aio
dev-infra
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 4.3 KB
.bazelrc -rw-r--r-- 6.5 KB
.bazelversion -rw-r--r-- 213 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 314 bytes
.gitignore -rw-r--r-- 726 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.nvmrc -rw-r--r-- 8 bytes
.pullapprove.yml -rw-r--r-- 44.1 KB
.yarnrc -rw-r--r-- 128 bytes
BUILD.bazel -rw-r--r-- 1.7 KB
CHANGELOG.md -rw-r--r-- 719.1 KB
CODE_OF_CONDUCT.md -rw-r--r-- 1.1 KB
CONTRIBUTING.md -rw-r--r-- 14.2 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 1.2 KB
WORKSPACE -rw-r--r-- 4.3 KB
browser-providers.conf.js -rw-r--r-- 8.9 KB
gulpfile.js -rw-r--r-- 1.2 KB
karma-js.conf.js -rw-r--r-- 7.6 KB
package.json -rw-r--r-- 8.2 KB
test-events.js -rw-r--r-- 259 bytes
test-main.js -rw-r--r-- 11.3 KB
tslint.json -rw-r--r-- 2.3 KB
yarn.lock -rw-r--r-- 674.8 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top