Merge branch 'master' into doubleTap-location

This commit is contained in:
Dimitar Topuzov
2020-03-10 18:23:49 +02:00
committed by GitHub
3 changed files with 17 additions and 12 deletions

View File

@@ -0,0 +1 @@
export declare function cssTreeParse(css: any, source: any): any;

View File

@@ -1116,7 +1116,7 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO
setPercent = options.setPercent || percentNotSupported; setPercent = options.setPercent || percentNotSupported;
options = null; options = null;
} }
if (length == "auto") { // tslint:disable-line if (length == "auto" || !length) { // tslint:disable-line
setPixels(this.nativeViewProtected, auto); setPixels(this.nativeViewProtected, auto);
} else if (typeof length === "number") { } else if (typeof length === "number") {
setPixels(this.nativeViewProtected, layout.round(layout.toDevicePixels(length))); setPixels(this.nativeViewProtected, layout.round(layout.toDevicePixels(length)));

View File

@@ -110,6 +110,19 @@ class CSSSource {
this.parse(); this.parse();
} }
public static fromDetect(cssOrAst: any, keyframes: KeyframesMap, fileName?: string): CSSSource {
if (typeof cssOrAst === "string") {
// raw-loader
return CSSSource.fromSource(cssOrAst, keyframes, fileName);
} else if (typeof cssOrAst === "object" && cssOrAst.type === "stylesheet" && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
// css-loader
return CSSSource.fromAST(cssOrAst, keyframes, fileName);
} else {
// css2json-loader
return CSSSource.fromSource(cssOrAst.toString(), keyframes, fileName);
}
}
public static fromURI(uri: string, keyframes: KeyframesMap): CSSSource { public static fromURI(uri: string, keyframes: KeyframesMap): CSSSource {
// webpack modules require all file paths to be relative to /app folder // webpack modules require all file paths to be relative to /app folder
const appRelativeUri = CSSSource.pathRelativeToApp(uri); const appRelativeUri = CSSSource.pathRelativeToApp(uri);
@@ -119,16 +132,7 @@ class CSSSource {
try { try {
const cssOrAst = global.loadModule(resolvedModuleName, true); const cssOrAst = global.loadModule(resolvedModuleName, true);
if (cssOrAst) { if (cssOrAst) {
if (typeof cssOrAst === "string") { return CSSSource.fromDetect(cssOrAst, keyframes, resolvedModuleName);
// raw-loader
return CSSSource.fromSource(cssOrAst, keyframes, resolvedModuleName);
} else if (typeof cssOrAst === "object" && cssOrAst.type === "stylesheet" && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
// css-loader
return CSSSource.fromAST(cssOrAst, keyframes, resolvedModuleName);
} else {
// css2json-loader
return CSSSource.fromSource(cssOrAst.toString(), keyframes, resolvedModuleName);
}
} }
} catch (e) { } catch (e) {
traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error); traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error);
@@ -325,7 +329,7 @@ export function removeTaggedAdditionalCSS(tag: String | Number): Boolean {
} }
export function addTaggedAdditionalCSS(cssText: string, tag?: string | Number): Boolean { export function addTaggedAdditionalCSS(cssText: string, tag?: string | Number): Boolean {
const parsed: RuleSet[] = CSSSource.fromSource(cssText, applicationKeyframes, undefined).selectors; const parsed: RuleSet[] = CSSSource.fromDetect(cssText, applicationKeyframes, undefined).selectors;
let changed = false; let changed = false;
if (parsed && parsed.length) { if (parsed && parsed.length) {
changed = true; changed = true;