feat(page): auto-add css className built from JS component name

This commit is contained in:
Adam Bradley
2015-12-10 11:34:12 -06:00
parent 315d4f235a
commit 9f0ab4a86e

View File

@ -8,7 +8,7 @@ import {Keyboard} from '../../util/keyboard';
import {ViewController} from './view-controller';
import {Animation} from '../../animations/animation';
import {SwipeBackGesture} from './swipe-back';
import {isBoolean, array} from '../../util/util';
import {isBoolean, array, pascalCaseToDashCase} from '../../util/util';
import {raf, rafFrames} from '../../util/dom';
/**
@ -920,6 +920,10 @@ export class NavController extends Ion {
let pageElementRef = this._viewManager.getHostElement(hostViewRef);
let component = this._viewManager.getComponent(pageElementRef);
// auto-add page css className created from component JS class name
let cssClassName = pascalCaseToDashCase(viewCtrl.componentType.name);
this._renderer.setElementClass(pageElementRef, cssClassName, true);
viewCtrl.addDestroy(() => {
// ensure the element is cleaned up for when the view pool reuses this element
this._renderer.setElementAttribute(pageElementRef, 'class', null);