question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v5.2.5] Error when using mixinColor

See original GitHub issue

Bug, feature request, or proposal:

When using the mixinColor like it is used in MatToolbar, my browsers throw errors.

What is the expected behavior?

No errors.

What is the current behavior?

When I use mixinColor like in MatToolbar, I get these errors when running my app in AOT (I also tried JIT):

Google Chrome 64-bit version 66.0 on Windows:

my-material.component.html:5 ERROR TypeError: Cannot read property 'nativeElement' of undefined
    at MyMaterialComponent.set [as color] (core.es5.js:277)
    at updateProp (core.js:12661)
    at checkAndUpdateDirectiveInline (core.js:12368)
    at checkAndUpdateNodeInline (core.js:13935)
    at checkAndUpdateNode (core.js:13878)
    at debugCheckAndUpdateNode (core.js:14771)
    at debugCheckDirectivesFn (core.js:14712)
    at Object.eval [as updateDirectives] (my-material.component.html:5)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:14697)
    at checkAndUpdateView (core.js:13844)

Firefox Quantum 64-bit version 59.0.2 on Windows:

Error: this._elementRef is undefined
Error: cyclic object value

Edge version 16.16299:

ERROR TypeError: Unable to get property 'nativeElement' of undefined or null reference
ERROR TypeError: Circular reference in value argument not supported

What are the steps to reproduce?

Here’s a StackBlitz illustrating the problem and throwing the error: https://stackblitz.com/edit/angular-material-theme-palette?file=app/ui/my-material/my-material.component.ts

Component model
import {
  ChangeDetectionStrategy,
  Component,
  ElementRef,
  ViewEncapsulation,
} from '@angular/core';
import { CanColor, mixinColor } from '@angular/material';

export class MyMaterialBase {
    constructor(public _elementRef: ElementRef) { }
}

export const _MyMaterialMixinBase = mixinColor(MyMaterialBase);

@Component({
    selector: 'my-material',
    styleUrls: ['my-material.component.scss'],
    templateUrl: 'my-material.component.html',
    host: {
        'class': 'my-material',
    },
    inputs: ['color'],
    changeDetection: ChangeDetectionStrategy.OnPush,
    encapsulation: ViewEncapsulation.None,
    preserveWhitespaces: false,
})
export class MyMaterialComponent
extends _MyMaterialMixinBase
implements CanColor {}

What is the use-case or motivation for changing an existing behavior?

Some documentation on using mixinColor would be nice.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular version 5.2.10 Angular Material version 5.2.5 TypeScript version 2.6.2 (when trying it out on localhost, I am not sure of StackBlitz)

Is there anything else we should know?

You are doing a great job!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jelbourncommented, Apr 25, 2018

It’s because the component has a dynamic base class due to the mixin, which Angular can’t resolve statically, so it doesn’t know do inject the dependencies of the base class.

FYI, the mixins aren’t intended to be a public API (that’s why they’re undocumented).

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Answers to Old Questions Headquarters - 2017-07-29 (page 2 ...
[ Natty ] python Error using ExtraTreesClassifier in scikit-learn By: zina 1.5; ... error: cannot get automation extension By: Bheemashankar Pattar 2.5;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found