Go to file
Misko Hevery 76698d38f7 refactor(ivy): Add style reconciliation algorithm (#34004)
This change introduces class/style reconciliation algorithm for DOM elements.
NOTE: The code is not yet hooked up, it will be used by future style algorithm.

Background:
Styling algorithm currently has [two paths](https://hackmd.io/@5zDGNGArSxiHhgvxRGrg-g/rycZk3N5S)
when computing how the style should be rendered.
1. A direct path which concatenates styling and uses `elemnent.className`/`element.style.cssText` and
2. A merge path which uses internal data structures and uses `element.classList.add/remove`/`element.style[property]`.

The situation is confusing and hard to follow/maintain. So a future PR will remove the merge-path and do everything with
direct-path. This however breaks when some other code adds class or style to the element without Angular's knowledge.
If this happens instead of switching from direct-path to merge-path algorithm, this change provides a different mental model
whereby we always do `direct-path` but the code which writes to the DOM detects the situation and reconciles the out of bound write.

The reconciliation process is as follows:
1. Detect that no one has modified `className`/`cssText` and if so just write directly (fast path).
2. If out of bounds write did occur, switch from writing using `className`/`cssText` to `element.classList.add/remove`/`element.style[property]`.
   This does require that the write function computes the difference between the previous Angular expected state and current Angular state.
   (This requires a parser. The advantage of having a parser is that we can support `style="width: {{exp}}px" kind of bindings.`)
   Compute the diff and apply it in non destructive way using `element.classList.add/remove`/`element.style[property]`

Properties of approach:
- If no out of bounds style modification:
  - Very fast code path: Just concatenate string in right order and write them to DOM.
  - Class list order is preserved
- If out of bounds style modification detected:
  - Penalty for parsing
  - Switch to non destructive modification: `element.classList.add/remove`/`element.style[property]`
  - Switch to alphabetical way of setting classes.

PR Close #34004
2020-01-24 12:21:39 -08:00
.circleci ci(docs-infra): use the correct version of yarn in `aio_monitoring_stable` (#34954) 2020-01-24 11:32:58 -08:00
.devcontainer build: update the recommended `Dockerfile` for VSCode remote development (#34697) 2020-01-09 13:31:14 -08:00
.github ci: rename `material-unit-tests` job to `components-repo-unit-tests` (#34898) 2020-01-23 13:29:02 -08:00
.vscode build: migrate references and scripts that set to build with ivy via compile=aot to use config=ivy (#33983) 2019-11-26 16:38:40 -05:00
.yarn build: vendor yarn using the .yarnrc yarn-path value (#34902) 2020-01-23 11:41:23 -08:00
aio fix(ivy): use any for generic context checks when !strictTemplates (#34649) 2020-01-23 10:31:48 -08:00
docs ci: rename `material-unit-tests` job to `components-repo-unit-tests` (#34898) 2020-01-23 13:29:02 -08:00
integration fix(ivy): don't detect changes on detached child embedded views (#34846) 2020-01-24 12:15:52 -08:00
modules perf(ivy): add more styling use-cases to benchmarks (#34923) 2020-01-24 08:58:29 -08:00
packages refactor(ivy): Add style reconciliation algorithm (#34004) 2020-01-24 12:21:39 -08:00
scripts ci: rename `material-unit-tests` job to `components-repo-unit-tests` (#34898) 2020-01-23 13:29:02 -08:00
third_party build: update to yarn@1.21.1 (#34384) 2019-12-16 07:39:58 -08:00
tools ci: rename `material-unit-tests` job to `components-repo-unit-tests` (#34898) 2020-01-23 13:29:02 -08:00
.bazelignore build: add integration/platform-server/node_modules to .bazelignore (#33765) 2019-11-22 16:52:08 -05:00
.bazelrc build: add --stamp flag to the release config (#34890) 2020-01-22 12:34:12 -05:00
.clang-format
.editorconfig build: use https link to editorconfig.org in .editorconfig (#27664) 2018-12-18 09:30:09 -08:00
.gitattributes test: fix ts api guardian and public guard tests on windows (#30105) 2019-04-26 16:32:22 -07:00
.gitignore feat: add direction property to locale files (#33556) 2019-12-03 15:58:09 -08:00
.mailmap
.nvmrc build: update .nvmrc to correct node version (#33636) 2019-11-06 21:23:07 +00:00
.yarnrc build: vendor yarn using the .yarnrc yarn-path value (#34902) 2020-01-23 11:41:23 -08:00
BUILD.bazel ci: fix saucelabs bazel tests terminating after 5min (#34707) 2020-01-09 13:30:39 -08:00
CHANGELOG.md release: cut the v9.0.0-rc.10 release 2020-01-22 11:23:21 -08:00
CODE_OF_CONDUCT.md docs: fix community tab in GitHub by copying CoC 2018-02-27 19:02:30 -08:00
CONTRIBUTING.md docs: document golden file requirement (#33900) 2020-01-07 10:58:53 -08:00
LICENSE build: bump year (#34651) 2020-01-13 07:21:43 -08:00
README.md docs: fix typo of Typescript to TypeScript (#32153) 2019-08-15 12:44:41 -07:00
WORKSPACE build: update to rules_nodejs 1.1.0 (#34736) 2020-01-15 14:58:07 -05:00
browser-providers.conf.js ci: re-enable chrome mobile tests on android (#32447) 2019-09-03 11:58:30 -07:00
gulpfile.js build: create bazel marco to test for circular dependencies (#34774) 2020-01-23 11:36:40 -08:00
karma-js.conf.js build: remove modules/angular1_router (#34551) 2020-01-07 10:42:30 -08:00
package.json build: create bazel marco to test for circular dependencies (#34774) 2020-01-23 11:36:40 -08:00
protractor-perf.conf.js fixup! test(ivy): make the test run with benchpress (#30449) 2019-05-16 20:04:04 -07:00
shims_for_IE.js
test-events.js refactor: rename unpatched event flag in Zone from `BLACK_LISTED_EVENTS` to `UNPATCHED_EVENTS` (#29617) 2019-10-04 08:44:58 -07:00
test-main.js feat(ivy): i18n - implement compile-time inlining (#32881) 2019-10-09 13:19:38 -07:00
tslint.json style: enforce disallowance of object constructor (#33211) 2019-12-03 10:08:25 -08:00
yarn.lock build: create bazel marco to test for circular dependencies (#34774) 2020-01-23 11:36:40 -08:00
yarn.lock.readme.md build: remove travisci leftovers (#27979) 2019-01-09 10:41:16 -08:00

README.md

CircleCI BrowserStack Status Join the chat at https://gitter.im/angular/angular npm version

Angular

Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages.

Quickstart

Get started in 5 minutes.

Changelog

Learn about the latest improvements.

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.