mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(page): auto-add css className built from JS component name
This commit is contained in:
@ -8,7 +8,7 @@ import {Keyboard} from '../../util/keyboard';
|
|||||||
import {ViewController} from './view-controller';
|
import {ViewController} from './view-controller';
|
||||||
import {Animation} from '../../animations/animation';
|
import {Animation} from '../../animations/animation';
|
||||||
import {SwipeBackGesture} from './swipe-back';
|
import {SwipeBackGesture} from './swipe-back';
|
||||||
import {isBoolean, array} from '../../util/util';
|
import {isBoolean, array, pascalCaseToDashCase} from '../../util/util';
|
||||||
import {raf, rafFrames} from '../../util/dom';
|
import {raf, rafFrames} from '../../util/dom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -920,6 +920,10 @@ export class NavController extends Ion {
|
|||||||
let pageElementRef = this._viewManager.getHostElement(hostViewRef);
|
let pageElementRef = this._viewManager.getHostElement(hostViewRef);
|
||||||
let component = this._viewManager.getComponent(pageElementRef);
|
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(() => {
|
viewCtrl.addDestroy(() => {
|
||||||
// ensure the element is cleaned up for when the view pool reuses this element
|
// ensure the element is cleaned up for when the view pool reuses this element
|
||||||
this._renderer.setElementAttribute(pageElementRef, 'class', null);
|
this._renderer.setElementAttribute(pageElementRef, 'class', null);
|
||||||
|
Reference in New Issue
Block a user