Style tests fixes

This commit is contained in:
vakrilov
2017-01-11 23:38:10 +02:00
parent 6cfe3601e0
commit e983295952
7 changed files with 114 additions and 105 deletions

View File

@@ -507,10 +507,10 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
value = defaultValue;
delete this[sourceKey];
} else {
this[sourceKey] = ValueSource.Css;
if (valueConverter && typeof value === "string") {
value = valueConverter(value);
}
this[sourceKey] = ValueSource.Css;
}
const currentValue: U = key in this ? this[key] : defaultValue;

View File

@@ -123,6 +123,9 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
get style(): Style {
return this._style;
}
set style(value) {
throw new Error("View.style property is read-only.");
}
get android(): any {
return undefined;

View File

@@ -34,7 +34,7 @@ export class Frame extends FrameBase {
public get _context(): any {
return FRAME_CONTEXT;
}
public set _context(value:any) {
public set _context(value: any) {
throw new Error("Frame _context is readonly");
}

View File

@@ -1,4 +1,4 @@
import { ViewBase, resetStyleProperties } from "ui/core/view-base";
import { ViewBase, resetCSSProperties } from "ui/core/view-base";
import { SyntaxTree, Keyframes, parse as parseCss, Node } from "css";
import { RuleSet, SelectorsMap, SelectorCore, SelectorsMatch, ChangeMap, fromAstNodes } from "ui/styling/css-selector";
import { KeyframeAnimationInfo, KeyframeAnimation } from "ui/animation/keyframe-animation";
@@ -22,7 +22,7 @@ export class CssState {
public apply(): void {
this.view._cancelAllAnimations();
resetStyleProperties(this.view.style);
resetCSSProperties(this.view.style);
let matchingSelectors = this.match.selectors.filter(sel => sel.dynamic ? sel.match(this.view) : true);
if (this.view.inlineStyleSelector) {
@@ -37,9 +37,13 @@ export class CssState {
ruleset.declarations.forEach(d => {
let name = `css-${d.property}`;
if (name in style) {
style[name] = d.value;
try {
style[name] = d.value;
} catch (e) {
traceWrite(`Failed to apply property [${d.property}] with value [${d.value}] to ${view}. ${e}`, traceCategories.Error, traceMessageType.error)
}
} else {
view[name] = d.value;
view[d.property] = d.value;
}
});
@@ -145,7 +149,7 @@ export class StyleScope {
let url = match && match[2];
if (url !== null && url !== undefined) {
let appDirectory = knownFolders.currentApp().path;
let appDirectory = knownFolders.currentApp().path;
let fileName = resolveFileNameFromUrl(url, appDirectory, File.exists);
if (fileName !== null) {