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.

ERROR TypeError: _this._renderer.addClass is not a function

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

An image within a toolbar should be able to have a class

What is the current behavior?

I do have a toolbar:

<mat-toolbar color="primary">
  <img src="assets/img/angular-logo.png">
  ...
</mat-toolbar>

And it’s working fine as long I do not add a class to the img.

If I do:

<mat-toolbar color="primary">
  <img class="logo-toolbar" src="assets/img/angular-logo.png">
  ...
</mat-toolbar>

Just adding a class throws an error:

ERROR TypeError: _this._renderer.addClass is not a function
    at common.js:2198
    at Array.forEach (<anonymous>)
    at NgClass.webpackJsonp.../../../common/esm5/common.js.NgClass._toggleClass (common.js:2196)
    at common.js:2156
    at Array.forEach (<anonymous>)
    at NgClass.webpackJsonp.../../../common/esm5/common.js.NgClass._applyInitialClasses (common.js:2156)
    at NgClass.set [as klass] (common.js:2048)
    at ClassDirective.set [as classBase] (flex-layout.es5.js:2819)
    at updateProp (core.js:12336)
    at checkAndUpdateDirectiveInline (core.js:12046)
    at checkAndUpdateNodeInline (core.js:13580)
    at checkAndUpdateNode (core.js:13523)
    at debugCheckAndUpdateNode (core.js:14384)
    at debugCheckDirectivesFn (core.js:14325)
    at Object.eval [as updateDirectives] (FeaturesComponent.html:3)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:14310)
    at checkAndUpdateView (core.js:13490)
    at callViewAction (core.js:13840)
    at execComponentViewsAction (core.js:13772)
    at checkAndUpdateView (core.js:13496)
    at callViewAction (core.js:13840)
    at execEmbeddedViewsAction (core.js:13798)
    at checkAndUpdateView (core.js:13491)
    at callViewAction (core.js:13840)
    at execComponentViewsAction (core.js:13772)
    at checkAndUpdateView (core.js:13496)
    at callWithDebugContext (core.js:14711)
    at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:14248)
    at ViewRef_.webpackJsonp.../../../core/esm5/core.js.ViewRef_.detectChanges (core.js:11292)
    at core.js:5783
    at Array.forEach (<anonymous>)
    at ApplicationRef.webpackJsonp.../../../core/esm5/core.js.ApplicationRef.tick (core.js:5783)
    at core.js:5616
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:392)
    at Object.onInvoke (core.js:4626)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (zone.js:142)
    at NgZone.webpackJsonp.../../../core/esm5/core.js.NgZone.run (core.js:4443)
    at Object.next (core.js:5616)
    at SafeSubscriber.schedulerFn [as _next] (core.js:4220)
    at SafeSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
    at SafeSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.next (Subscriber.js:185)
    at Subscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125)
    at Subscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
    at EventEmitter.webpackJsonp.../../../../rxjs/Subject.js.Subject.next (Subject.js:55)
    at EventEmitter.webpackJsonp.../../../core/esm5/core.js.EventEmitter.emit (core.js:4200)
    at checkStable (core.js:4591)
    at Object.onHasTask (core.js:4639)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.hasTask (zone.js:445)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate._updateTaskCount (zone.js:465)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone._updateTaskCount (zone.js:289)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:209)
    at drainMicroTaskQueue (zone.js:602)
    at <anonymous>

What are the steps to reproduce?

git clone https://github.com/maxime1992/angular-ngrx-starter.git
cd angular-ngrx-starter
git checkout repro-bug-material
yarn
ng serve

Bug happen at http://localhost:4200

Open file app/features/features.component.html and remove the class="logo-toolbar" from the img within the navbar.

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

@angular/cli: 1.5.0-beta.4 node: 8.6.0 os: linux x64 @angular/animations: 5.0.0-rc.1 @angular/cdk: 2.0.0-beta.12 @angular/common: 5.0.0-rc.1 @angular/compiler: 5.0.0-rc.1 @angular/core: 5.0.0-rc.1 @angular/flex-layout: 2.0.0-beta.9 @angular/forms: 5.0.0-rc.1 @angular/http: 5.0.0-rc.1 @angular/material: 2.0.0-beta.12 @angular/platform-browser: 5.0.0-rc.1 @angular/platform-browser-dynamic: 5.0.0-rc.1 @angular/router: 5.0.0-rc.1 @angular/service-worker: 5.0.0-rc.1 @angular/cli: 1.5.0-beta.4 @angular/compiler-cli: 5.0.0-rc.1 @angular/language-service: 5.0.0-rc.1 typescript: 2.5.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

1reaction
amir-zahedicommented, Oct 26, 2017

Any news on when the next release will be @ghd8 ?

1reaction
ghd8commented, Oct 11, 2017

Yes, you can. Should be fixed in the next angular/flex-layout release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript error "el.addClass i s not a function" when trying to ...
One basic check: are you certain that this.appendChild(createCalendarContainer()) is being executed before var calendarEl = document.
Read more >
TypeError: addClass is not a function in JavaScript | bobbyhadz
The "addClass is not a function" error occurs for multiple reasons: Calling the function on a value that is not a set of...
Read more >
Renderer2 - Angular
Use a custom renderer to bypass Angular's templating and make custom UI changes that can't be expressed declaratively. For example if you need...
Read more >
Angular Renderer2 Example - ConcretePage.com
This page will walk through Angular Renderer2 example. The Renderer2 is used for UI rendering manipulation. Using Renderer2 ,
Read more >
Renderer2 Example: Manipulating DOM in Angular
Why not ElementRef? ... We can use the nativeElement property of the ElelemtRef to manipulate the DOM. We learned this in our last...
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