mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 15:51:16 +08:00
perf(platform): remove from critical path
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
import 'ionicons';
|
||||
import { createConfigController } from './config-controller';
|
||||
import { PLATFORM_CONFIGS, detectPlatforms, readQueryParam } from './platform-configs';
|
||||
|
||||
import { Config } from './config';
|
||||
import { configFromURL, isIOS } from '../utils/platform';
|
||||
|
||||
const Ionic = (window as any).Ionic = (window as any).Ionic || {};
|
||||
|
||||
declare const Context: any;
|
||||
|
||||
// queue used to coordinate DOM reads and
|
||||
@ -13,25 +11,18 @@ Object.defineProperty(Ionic, 'queue', {
|
||||
get: () => Context.queue
|
||||
});
|
||||
|
||||
if (!Context.platforms) {
|
||||
Context.platforms = detectPlatforms(window.location.href, window.navigator.userAgent, PLATFORM_CONFIGS, 'core');
|
||||
}
|
||||
|
||||
if (!Context.readQueryParam) {
|
||||
Context.readQueryParam = readQueryParam;
|
||||
}
|
||||
|
||||
// create the Ionic.config from raw config object (if it exists)
|
||||
// and convert Ionic.config into a ConfigApi that has a get() fn
|
||||
Ionic.config = Context.config = createConfigController(
|
||||
Ionic.config,
|
||||
Context.platforms
|
||||
);
|
||||
const config = Ionic.config = Context.config = new Config({
|
||||
...configFromURL(window),
|
||||
...Ionic.config,
|
||||
});
|
||||
|
||||
// first see if the mode was set as an attribute on <html>
|
||||
// which could have been set by the user, or by prerendering
|
||||
// otherwise get the mode via config settings, and fallback to md
|
||||
Ionic.mode = Context.mode = document.documentElement.getAttribute('mode') || Context.config.get('mode', 'md');
|
||||
|
||||
// ensure we've got the mode attribute set on <html>
|
||||
document.documentElement.setAttribute('mode', Ionic.mode);
|
||||
const documentElement = document.documentElement;
|
||||
const mode = config.get('mode', documentElement.getAttribute('mode') || (isIOS(window) ? 'ios' : 'md'));
|
||||
Ionic.mode = Context.mode = mode;
|
||||
config.set('mode', mode);
|
||||
documentElement.setAttribute('mode', Ionic.mode);
|
||||
|
||||
Reference in New Issue
Block a user