mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(inputs): apply ng form classes (#18820)
This commit is contained in:
@ -3,6 +3,7 @@ import { applyPolyfills, defineCustomElements } from '@ionic/core/loader';
|
|||||||
|
|
||||||
import { Config } from './providers/config';
|
import { Config } from './providers/config';
|
||||||
import { IonicWindow } from './types/interfaces';
|
import { IonicWindow } from './types/interfaces';
|
||||||
|
import { raf } from './util/util';
|
||||||
|
|
||||||
export function appInitialize(config: Config, doc: Document, zone: NgZone) {
|
export function appInitialize(config: Config, doc: Document, zone: NgZone) {
|
||||||
return (): any => {
|
return (): any => {
|
||||||
@ -23,12 +24,8 @@ export function appInitialize(config: Config, doc: Document, zone: NgZone) {
|
|||||||
return defineCustomElements(win, {
|
return defineCustomElements(win, {
|
||||||
exclude: ['ion-tabs', 'ion-tab'],
|
exclude: ['ion-tabs', 'ion-tab'],
|
||||||
syncQueue: true,
|
syncQueue: true,
|
||||||
|
raf,
|
||||||
jmp: (h: any) => zone.runOutsideAngular(h),
|
jmp: (h: any) => zone.runOutsideAngular(h),
|
||||||
raf: h => {
|
|
||||||
return zone.runOutsideAngular(() => {
|
|
||||||
return (win.__zone_symbol__requestAnimationFrame) ? win.__zone_symbol__requestAnimationFrame(h) : requestAnimationFrame(h);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
ael(elm, eventName, cb, opts) {
|
ael(elm, eventName, cb, opts) {
|
||||||
(elm as any)[aelFn](eventName, cb, opts);
|
(elm as any)[aelFn](eventName, cb, opts);
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { ElementRef, HostListener } from '@angular/core';
|
import { ElementRef, HostListener } from '@angular/core';
|
||||||
import { ControlValueAccessor } from '@angular/forms';
|
import { ControlValueAccessor } from '@angular/forms';
|
||||||
|
|
||||||
|
import { raf } from '../../util/util';
|
||||||
|
|
||||||
export class ValueAccessor implements ControlValueAccessor {
|
export class ValueAccessor implements ControlValueAccessor {
|
||||||
|
|
||||||
private onChange: (value: any) => void = () => {/**/};
|
private onChange: (value: any) => void = () => {/**/};
|
||||||
@ -42,14 +44,16 @@ export class ValueAccessor implements ControlValueAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setIonicClasses(element: ElementRef) {
|
export function setIonicClasses(element: ElementRef) {
|
||||||
const input = element.nativeElement as HTMLElement;
|
raf(() => {
|
||||||
const classes = getClasses(input);
|
const input = element.nativeElement as HTMLElement;
|
||||||
setClasses(input, classes);
|
const classes = getClasses(input);
|
||||||
|
setClasses(input, classes);
|
||||||
|
|
||||||
const item = input.closest('ion-item');
|
const item = input.closest('ion-item');
|
||||||
if (item) {
|
if (item) {
|
||||||
setClasses(item, classes);
|
setClasses(item, classes);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClasses(element: HTMLElement) {
|
function getClasses(element: HTMLElement) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import { HTMLStencilElement } from '../types/interfaces';
|
import { HTMLStencilElement } from '../types/interfaces';
|
||||||
|
|
||||||
|
export const raf = (h: any) => {
|
||||||
|
const win = window as any;
|
||||||
|
return (win.__zone_symbol__requestAnimationFrame) ? win.__zone_symbol__requestAnimationFrame(h) : requestAnimationFrame(h);
|
||||||
|
};
|
||||||
|
|
||||||
export function proxyMethod(ctrlName: string, doc: Document, methodName: string, ...args: any[]) {
|
export function proxyMethod(ctrlName: string, doc: Document, methodName: string, ...args: any[]) {
|
||||||
const controller = ensureElementInBody(ctrlName, doc);
|
const controller = ensureElementInBody(ctrlName, doc);
|
||||||
return controller.componentOnReady()
|
return controller.componentOnReady()
|
||||||
|
Reference in New Issue
Block a user