Skip to content

Commit bf02f7a

Browse files
authored
Merge branch 'master' into doubleTap-location
2 parents 4952ca6 + 916ec8b commit bf02f7a

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function cssTreeParse(css: any, source: any): any;

nativescript-core/ui/core/view/view.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO
11161116
setPercent = options.setPercent || percentNotSupported;
11171117
options = null;
11181118
}
1119-
if (length == "auto") { // tslint:disable-line
1119+
if (length == "auto" || !length) { // tslint:disable-line
11201120
setPixels(this.nativeViewProtected, auto);
11211121
} else if (typeof length === "number") {
11221122
setPixels(this.nativeViewProtected, layout.round(layout.toDevicePixels(length)));

nativescript-core/ui/styling/style-scope.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ class CSSSource {
110110
this.parse();
111111
}
112112

113+
public static fromDetect(cssOrAst: any, keyframes: KeyframesMap, fileName?: string): CSSSource {
114+
if (typeof cssOrAst === "string") {
115+
// raw-loader
116+
return CSSSource.fromSource(cssOrAst, keyframes, fileName);
117+
} else if (typeof cssOrAst === "object" && cssOrAst.type === "stylesheet" && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
118+
// css-loader
119+
return CSSSource.fromAST(cssOrAst, keyframes, fileName);
120+
} else {
121+
// css2json-loader
122+
return CSSSource.fromSource(cssOrAst.toString(), keyframes, fileName);
123+
}
124+
}
125+
113126
public static fromURI(uri: string, keyframes: KeyframesMap): CSSSource {
114127
// webpack modules require all file paths to be relative to /app folder
115128
const appRelativeUri = CSSSource.pathRelativeToApp(uri);
@@ -119,16 +132,7 @@ class CSSSource {
119132
try {
120133
const cssOrAst = global.loadModule(resolvedModuleName, true);
121134
if (cssOrAst) {
122-
if (typeof cssOrAst === "string") {
123-
// raw-loader
124-
return CSSSource.fromSource(cssOrAst, keyframes, resolvedModuleName);
125-
} else if (typeof cssOrAst === "object" && cssOrAst.type === "stylesheet" && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
126-
// css-loader
127-
return CSSSource.fromAST(cssOrAst, keyframes, resolvedModuleName);
128-
} else {
129-
// css2json-loader
130-
return CSSSource.fromSource(cssOrAst.toString(), keyframes, resolvedModuleName);
131-
}
135+
return CSSSource.fromDetect(cssOrAst, keyframes, resolvedModuleName);
132136
}
133137
} catch (e) {
134138
traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error);
@@ -325,7 +329,7 @@ export function removeTaggedAdditionalCSS(tag: String | Number): Boolean {
325329
}
326330

327331
export function addTaggedAdditionalCSS(cssText: string, tag?: string | Number): Boolean {
328-
const parsed: RuleSet[] = CSSSource.fromSource(cssText, applicationKeyframes, undefined).selectors;
332+
const parsed: RuleSet[] = CSSSource.fromDetect(cssText, applicationKeyframes, undefined).selectors;
329333
let changed = false;
330334
if (parsed && parsed.length) {
331335
changed = true;

0 commit comments

Comments
 (0)