angular-cn/packages/core/schematics/test/google3
crisbeto c0955975f4 feat(core): add automatic migration from Renderer to Renderer2 (#30936)
Adds a schematic and tslint rule that automatically migrate the consumer from `Renderer` to `Renderer2`. Supports:
* Renaming imports.
* Renaming property and method argument types.
* Casting to `Renderer`.
* Mapping all of the methods from the `Renderer` to `Renderer2`.

Note that some of the `Renderer` methods don't map cleanly between renderers. In these cases the migration adds a helper function at the bottom of the file which ensures that we generate valid code with the same return value as before. E.g. here's what the migration for `createText` looks like.

Before:
```
class SomeComponent {
  createAndAddText() {
    const node = this._renderer.createText(this._element.nativeElement, 'hello');
    node.textContent += ' world';
  }
}
```

After:
```
class SomeComponent {
  createAndAddText() {
    const node = __rendererCreateTextHelper(this._renderer, this._element.nativeElement, 'hello');
    node.textContent += ' world';
  }
}

function __rendererCreateTextHelper(renderer: any, parent: any, value: any) {
  const node = renderer.createText(value);
  if (parent) {
    renderer.appendChild(parent, node);
  }
  return node;
}
```

This PR resolves FW-1344.

PR Close #30936
2019-07-03 09:03:37 -07:00
..
explicit_query_timing_rule_spec.ts refactor(core): static-query schematic should check templates (#29713) 2019-04-11 08:22:44 -07:00
injectable_pipe_spec.ts fix(ivy): injectable pipe schematic generating incorrect import statements (#30170) 2019-04-29 09:39:11 -07:00
no_template_variable_assignment_rule_spec.ts feat(core): template-var-assignment update schematic (#29608) 2019-04-02 15:47:32 -07:00
renderer_to_renderer2_spec.ts feat(core): add automatic migration from Renderer to Renderer2 (#30936) 2019-07-03 09:03:37 -07:00