Fix flexbox css not applied. Fix addCss duplicating some selectors.

This commit is contained in:
Panayot Cankov
2017-02-23 16:41:08 +02:00
parent ac90b9db2b
commit dc97ed24f9
3 changed files with 15 additions and 30 deletions

View File

@ -2,11 +2,8 @@ import { FlexboxLayout } from "ui/layouts/flexbox-layout";
function set(what: string) { function set(what: string) {
return function(args) { return function(args) {
// args.object.page.getViewById("container")[what] = args.object.text;
let containerCss = " #container { " + args.object.tag + " }" ; let containerCss = " #container { " + args.object.tag + " }" ;
// console.log(containerCss);
args.object.page.addCss(containerCss); args.object.page.addCss(containerCss);
// console.log(args.object.page.css);
} }
} }

View File

@ -392,16 +392,3 @@ const flexProperty = new ShorthandProperty<Style, string>({
} }
}) })
flexProperty.register(Style); flexProperty.register(Style);
Style.prototype.flexDirection = flexDirectionProperty.defaultValue;
Style.prototype.flexWrap = flexWrapProperty.defaultValue;
Style.prototype.justifyContent = justifyContentProperty.defaultValue;
Style.prototype.alignItems = alignItemsProperty.defaultValue;
Style.prototype.alignContent = alignContentProperty.defaultValue;
Style.prototype.order = orderProperty.defaultValue;
Style.prototype.flexGrow = flexGrowProperty.defaultValue;
Style.prototype.flexShrink = flexShrinkProperty.defaultValue;
Style.prototype.flexWrapBefore = flexWrapBeforeProperty.defaultValue;
Style.prototype.alignSelf = alignSelfProperty.defaultValue;
// No flex-basis in our implementation.

View File

@ -135,7 +135,7 @@ export class StyleScope {
private _statesByKey = {}; private _statesByKey = {};
private _viewIdToKey = {}; private _viewIdToKey = {};
private _css: string; private _css: string = "";
private _cssFileName: string; private _cssFileName: string;
private _mergedCssSelectors: RuleSet[]; private _mergedCssSelectors: RuleSet[];
private _localCssSelectors: RuleSet[] = []; private _localCssSelectors: RuleSet[] = [];
@ -154,25 +154,26 @@ export class StyleScope {
} }
public addCss(cssString: string, cssFileName?: string): void { public addCss(cssString: string, cssFileName?: string): void {
this.setCss(cssString, cssFileName, true); this.appendCss(cssString, cssFileName)
} }
private setCss(cssString: string, cssFileName?: string, append: boolean = false): void { private setCss(cssString: string, cssFileName?): void {
this._css = this._css && append ? this._css + cssString : cssString; this._css = cssString;
if (cssFileName) {
this._cssFileName = cssFileName;
}
this._reset(); this._reset();
this._localCssSelectors = createSelectorsFromCss(this._css, cssFileName, this._keyframes);
this._localCssSelectorVersion++;
this.ensureSelectors();
}
const parsedSelectors = createSelectorsFromCss(this._css, cssFileName, this._keyframes); private appendCss(cssString: string, cssFileName?): void {
if (!cssString) {
if (append) { return;
this._localCssSelectors.push.apply(this._localCssSelectors, parsedSelectors);
} else {
this._localCssSelectors = parsedSelectors;
} }
this._css = this._css + cssString;
this._reset();
let parsedCssSelectors = createSelectorsFromCss(cssString, cssFileName, this._keyframes);
this._localCssSelectors.push.apply(this._localCssSelectors, parsedCssSelectors);
this._localCssSelectorVersion++; this._localCssSelectorVersion++;
this.ensureSelectors(); this.ensureSelectors();
} }