lib/core/utils/preload-cssom.js
function parseNonCrossOriginStylesheet(sheet, options, priority) {
	const q = axe.utils.queue();

	/**
	 * `sheet.cssRules` throws an error on `cross-origin` stylesheets
	 */
	const cssRules = sheet.cssRules;

	const rules = Array.from(cssRules);
	if (!rules) {
		return q;
	}

	/**
	 * reference -> https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
	 */
	const cssImportRules = rules.filter(r => r.type === 3); // type === 3 -> CSSRule.IMPORT_RULE

	/**
	 * when no `@import` rules in given sheet
	 * -> resolve the current `sheet` & exit
	 */
	if (!cssImportRules.length) {
		q.defer(resolve =>
			resolve({
				isExternal: false,
				priority,
				root: options.rootNode,
				shadowId: options.shadowId,
				sheet
			})
		);

		// exit
		return q;
	}

	/**
	 * iterate `@import` rules and fetch styles
	 */
	cssImportRules.forEach((importRule, cssRuleIndex) =>
		q.defer((resolve, reject) => {
			const importUrl = importRule.href;
			const newPriority = [...priority, cssRuleIndex];
			const axiosOptions = {
				method: 'get',
				url: importUrl,
				timeout: options.timeout
			};
			axe.imports
				.axios(axiosOptions)
				.then(({ data }) =>
					resolve(
						options.convertDataToStylesheet({
							data,
							isExternal: true,
							priority: newPriority,
							root: options.rootNode,
							shadowId: options.shadowId
						})
					)
				)
				.catch(reject);
		})
	);

	const nonImportCSSRules = rules.filter(r => r.type !== 3);

	// no further rules to process in this sheet
	if (!nonImportCSSRules.length) {
		return q;
	}

	// convert all `nonImportCSSRules` style rules into `text` and defer into queue
	q.defer(resolve =>
		resolve(
			options.convertDataToStylesheet({
				data: nonImportCSSRules.map(rule => rule.cssText).join(),
				isExternal: false,
				priority,
				root: options.rootNode,
				shadowId: options.shadowId
			})
		)
	);

	return q;
}
function parseNonCrossOriginStylesheet(sheet, options, priority) {
	const q = axe.utils.queue();

	/**
	 * `sheet.cssRules` throws an error on `cross-origin` stylesheets
	 */
	const cssRules = sheet.cssRules;

	const rules = Array.from(cssRules);
	if (!rules) {
		return q;
	}

	/**
	 * reference -> https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
	 */
	const cssImportRules = rules.filter(r => r.type === 3); // type === 3 -> CSSRule.IMPORT_RULE

	/**
	 * when no `@import` rules in given sheet
	 * -> resolve the current `sheet` & exit
	 */
	if (!cssImportRules.length) {
		q.defer(resolve =>
			resolve({
				isExternal: false,
				priority,
				root: options.rootNode,
				shadowId: options.shadowId,
				sheet
			})
		);

		// exit
		return q;
	}

	/**
	 * iterate `@import` rules and fetch styles
	 */
	cssImportRules.forEach((importRule, cssRuleIndex) =>
		q.defer((resolve, reject) => {
			const importUrl = importRule.href;
			const newPriority = [...priority, cssRuleIndex];
			const axiosOptions = {
				method: 'get',
				url: importUrl,
				timeout: options.timeout
			};
			axe.imports
				.axios(axiosOptions)
				.then(({ data }) =>
					resolve(
						options.convertDataToStylesheet({
							data,
							isExternal: true,
							priority: newPriority,
							root: options.rootNode,
							shadowId: options.shadowId
						})
					)
				)
				.catch(reject);
		})
	);

	const nonImportCSSRules = rules.filter(r => r.type !== 3);

	// no further rules to process in this sheet
	if (!nonImportCSSRules.length) {
		return q;
	}

	// convert all `nonImportCSSRules` style rules into `text` and defer into queue
	q.defer(resolve =>
		resolve(
			options.convertDataToStylesheet({
				data: nonImportCSSRules.map(rule => rule.cssText).join(),
				isExternal: false,
				priority,
				root: options.rootNode,
				shadowId: options.shadowId
			})
		)
	);

	return q;
}
function parseNonCrossOriginStylesheet ( sheet , options , priority ) { const q = axe . utils . queue ( ) ; /**
	 * `sheet.cssRules` throws an error on `cross-origin` stylesheets
	 */ const cssRules = sheet . cssRules ; const rules = Array . from ( cssRules ) ; if ( ! rules ) { return q ; } /**
	 * reference -> https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
	 */ const cssImportRules = rules . filter ( r => r . type === 3 ) ; // type === 3 -> CSSRule.IMPORT_RULE /**
	 * when no `@import` rules in given sheet
	 * -> resolve the current `sheet` & exit
	 */ if ( ! cssImportRules . length ) { q . defer ( resolve => resolve ( { isExternal : false , priority , root : options . rootNode , shadowId : options . shadowId , sheet } ) ) ; // exit return q ; } /**
	 * iterate `@import` rules and fetch styles
	 */ cssImportRules . forEach ( ( importRule , cssRuleIndex ) => q . defer ( ( resolve , reject ) => { const importUrl = importRule . href ; const newPriority = [ ... priority , cssRuleIndex ] ; const axiosOptions = { method : 'get' , url : importUrl , timeout : options . timeout } ; axe . imports . axios ( axiosOptions ) . then ( ( { data } ) => resolve ( options . convertDataToStylesheet ( { data , isExternal : true , priority : newPriority , root : options . rootNode , shadowId : options . shadowId } ) ) ) . catch ( reject ) ; } ) ) ; const nonImportCSSRules = rules . filter ( r => r . type !== 3 ) ; // no further rules to process in this sheet if ( ! nonImportCSSRules . length ) { return q ; } // convert all `nonImportCSSRules` style rules into `text` and defer into queue q . defer ( resolve => resolve ( options . convertDataToStylesheet ( { data : nonImportCSSRules . map ( rule => rule . cssText ) . join ( ) , isExternal : false , priority , root : options . rootNode , shadowId : options . shadowId } ) ) ) ; return q ; }
Parse non cross-origin stylesheets

@param {Object} sheet CSSStylesheet object
@param {Object} options `loadCssom` options
@param {Array<Number>} priority sheet priority
Parse non cross - origin stylesheets