@@ -94,10 +94,6 @@ export const enum ClearStyleOptions {
9494 all = 3
9595}
9696
97- // IE needs to inject styles using cssText. However, we need to evaluate this lazily, so this
98- // value will initialize as undefined, and later will be set once on first loadStyles injection.
99- let _injectStylesWithCssText : boolean ;
100-
10197// Store the theming state in __themeState__ global scope for reuse in the case of duplicate
10298// load-themed-styles hosted on the page.
10399const _root : any = ( typeof window === 'undefined' ) ? global : window ; // tslint:disable-line:no-any
@@ -166,9 +162,6 @@ function initializeThemeState(): IThemeState {
166162export function loadStyles ( styles : string | ThemableArray , loadAsync : boolean = false ) : void {
167163 measure ( ( ) => {
168164 const styleParts : ThemableArray = Array . isArray ( styles ) ? styles : splitStyles ( styles ) ;
169- if ( _injectStylesWithCssText === undefined ) {
170- _injectStylesWithCssText = shouldUseCssText ( ) ;
171- }
172165 const {
173166 mode,
174167 buffer,
@@ -238,8 +231,6 @@ function applyThemableStyles(stylesArray: ThemableArray, styleRecord?: IStyleRec
238231 if ( _themeState . loadStyles ) {
239232 _themeState . loadStyles ( resolveThemableArray ( stylesArray ) . styleString , stylesArray ) ;
240233 } else {
241- _injectStylesWithCssText ?
242- registerStylesIE ( stylesArray , styleRecord ) :
243234 registerStyles ( stylesArray ) ;
244235 }
245236}
@@ -410,63 +401,3 @@ function registerStyles(styleArray: ThemableArray): void {
410401 _themeState . registeredStyles . push ( record ) ;
411402 }
412403}
413-
414- /**
415- * Registers a set of style text, for IE 9 and below, which has a ~30 style element limit so we need
416- * to register slightly differently.
417- * @param {ThemableArray } styleArray Array of IThemingInstruction objects to register.
418- * @param {IStyleRecord } styleRecord May specify a style Element to update.
419- */
420- function registerStylesIE ( styleArray : ThemableArray , styleRecord ?: IStyleRecord ) : void {
421- const head : HTMLHeadElement = document . getElementsByTagName ( 'head' ) [ 0 ] ;
422- const registeredStyles : IStyleRecord [ ] = _themeState . registeredStyles ;
423- let lastStyleElement : IExtendedHtmlStyleElement = _themeState . lastStyleElement ;
424-
425- const stylesheet : IStyleSheet | undefined = lastStyleElement ? lastStyleElement . styleSheet : undefined ;
426- const lastStyleContent : string = stylesheet ? stylesheet . cssText : '' ;
427- let lastRegisteredStyle : IStyleRecord = registeredStyles [ registeredStyles . length - 1 ] ;
428- const resolvedStyleText : string = resolveThemableArray ( styleArray ) . styleString ;
429-
430- if ( ! lastStyleElement || ( lastStyleContent . length + resolvedStyleText . length ) > MAX_STYLE_CONTENT_SIZE ) {
431- lastStyleElement = document . createElement ( 'style' ) as IExtendedHtmlStyleElement ;
432- lastStyleElement . type = 'text/css' ;
433-
434- if ( styleRecord ) {
435- head . replaceChild ( lastStyleElement , styleRecord . styleElement ) ;
436- styleRecord . styleElement = lastStyleElement ;
437- } else {
438- head . appendChild ( lastStyleElement ) ;
439- }
440-
441- if ( ! styleRecord ) {
442- lastRegisteredStyle = {
443- styleElement : lastStyleElement ,
444- themableStyle : styleArray
445- } ;
446- registeredStyles . push ( lastRegisteredStyle ) ;
447- }
448- }
449-
450- lastStyleElement . styleSheet . cssText += detokenize ( resolvedStyleText ) ;
451- Array . prototype . push . apply ( lastRegisteredStyle . themableStyle , styleArray ) ; // concat in-place
452-
453- // Preserve the theme state.
454- _themeState . lastStyleElement = lastStyleElement ;
455- }
456-
457- /**
458- * Checks to see if styleSheet exists as a property off of a style element.
459- * This will determine if style registration should be done via cssText (<= IE9) or not
460- */
461- function shouldUseCssText ( ) : boolean {
462- let useCSSText : boolean = false ;
463-
464- if ( typeof document !== 'undefined' ) {
465- const emptyStyle : IExtendedHtmlStyleElement = document . createElement ( 'style' ) as IExtendedHtmlStyleElement ;
466-
467- emptyStyle . type = 'text/css' ;
468- useCSSText = ! ! emptyStyle . styleSheet ;
469- }
470-
471- return useCSSText ;
472- }
0 commit comments