Skip to content

refactor: move away from deprecated apis - #3836

Merged
mmalerba merged 1 commit into
angular:masterfrom
crisbeto:ng-4-deprecated-apis
Apr 28, 2017
Merged

refactor: move away from deprecated apis#3836
mmalerba merged 1 commit into
angular:masterfrom
crisbeto:ng-4-deprecated-apis

Conversation

@crisbeto

Copy link
Copy Markdown
Member

Moves away from the APIs that were deprecated in Angular 4. They include:

  • Switching from using OpaqueToken to InjectionToken.
  • Moving from Renderer to Renderer2.
  • Changing the Injector.get(thing: any) usages to use the new signature Injector.get<T>(thing: T).

@googlebotgooglebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 29, 2017
@crisbeto
crisbetoforce-pushed the ng-4-deprecated-apis branch 2 times, most recently from 1ef8835 to 7579ed8CompareMarch 29, 2017 21:38
TestBed,
} from '@angular/core/testing';
import {NgControl, FormsModule, ReactiveFormsModule, FormControl} from '@angular/forms';
import {NgModel, FormsModule, ReactiveFormsModule, FormControl} from '@angular/forms';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kara is NgModel the right type here?

_setElementColor(color: string, isAdd: boolean) {
if (color != null && color != '') {
this._renderer.setElementClass(this._getHostElement(), `mat-${color}`, isAdd);
if (isAdd) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can kill this entire function now and just do the null check in _updateColor and call addClass / removeClass directly there.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is used in a couple of other places, as well as inside the button.html so it may be more convenient to keep it. Otherwise we'd need to do this._elementRef.nativeElement all over the place.

Comment threadsrc/lib/core/ripple/ripple.ts Outdated
};

/** Injection token that can be used to specify the global ripple options. */
export const MD_RIPPLE_GLOBAL_OPTIONS = new InjectionToken<RippleGlobalOptions>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally prefer line breaking at the higher syntactic level, e.g.:

exportconstMD_RIPPLE_GLOBAL_OPTIONS=newInjectionToken<RippleGlobalOptions>('md-ripple-global-options');

(at the assignment)

@crisbeto
crisbetoforce-pushed the ng-4-deprecated-apis branch from 7579ed8 to 87e7f79CompareApril 5, 2017 04:35
@crisbeto

Copy link
Copy Markdown
MemberAuthor

Rebased and addressed some of the feedback @jelbourn.

@jelbournjelbourn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbournjelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Apr 6, 2017
@jelbourn

jelbourn commented Apr 11, 2017

Copy link
Copy Markdown
Contributor

This is a breaking change because Renderer was part of the API for focus origin monitor.

Caretaker will need to update Google call sites.

@jelbournjelbourn added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 11, 2017
@karakara added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Apr 21, 2017
@karakara assigned crisbeto and unassigned jelbournApr 21, 2017
@crisbeto
crisbetoforce-pushed the ng-4-deprecated-apis branch from 584aa2a to 51c6d92CompareApril 22, 2017 14:23
@crisbetocrisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Apr 22, 2017
@crisbeto

Copy link
Copy Markdown
MemberAuthor

Rebased. Should I remove the presubmit failures tag @kara?

@crisbeto
crisbetoforce-pushed the ng-4-deprecated-apis branch 2 times, most recently from afff9f5 to dd3329eCompareApril 28, 2017 16:50
Moves away from the APIs that were deprecated in Angular 4. They include:
* Switching from using `OpaqueToken` to `InjectionToken`.
* Moving from `Renderer` to `Renderer2`.
* Changing the `Injector.get(thing: any)` usages to use the new signature `Injector.get<T>(thing: T)`.
@crisbeto
crisbetoforce-pushed the ng-4-deprecated-apis branch from dd3329e to 1c03ac6CompareApril 28, 2017 16:56
@mmalerba

Copy link
Copy Markdown
Contributor

It looks like the presubmit failures are because one of the teams in google is injecting the FocusOriginMonitor and the Renderer for one of their components and then calling focusVia with the Renderer. Do we want to make the FocusOriginMonitor accept Renderer2 | Renderer? or should we just refactor that project's code?

@crisbeto

crisbeto commented Apr 28, 2017

Copy link
Copy Markdown
MemberAuthor

It may be better to refactor it. We could have a solution that accepts both, but it would add some bloat and at some point we'll have to deprecate it anyway.

@jelbourn

Copy link
Copy Markdown
Contributor

@mmalerba if it's not widespread we should just change the team's code

@mmalerbammalerba removed the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 28, 2017
@mmalerba
mmalerba merged commit 29e503a into angular:masterApr 28, 2017
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-botangular-automatic-lock-botBot locked and limited conversation to collaborators Sep 6, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: mergeThe PR is ready for merge by the caretakercla: yesPR author has agreed to Google's Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@crisbeto@jelbourn@mmalerba@kara@googlebot