mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Merge pull request #3700 from NativeScript/fix-flexbox
Fix flexbox css not applied. Fix addCss duplicating some selectors.
This commit is contained in:
@ -2,11 +2,8 @@ import { FlexboxLayout } from "ui/layouts/flexbox-layout";
|
||||
|
||||
function set(what: string) {
|
||||
return function(args) {
|
||||
// args.object.page.getViewById("container")[what] = args.object.text;
|
||||
let containerCss = " #container { " + args.object.tag + " }" ;
|
||||
// console.log(containerCss);
|
||||
args.object.page.addCss(containerCss);
|
||||
// console.log(args.object.page.css);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,16 +392,3 @@ const flexProperty = new ShorthandProperty<Style, string>({
|
||||
}
|
||||
})
|
||||
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.
|
||||
|
@ -135,7 +135,7 @@ export class StyleScope {
|
||||
private _statesByKey = {};
|
||||
private _viewIdToKey = {};
|
||||
|
||||
private _css: string;
|
||||
private _css: string = "";
|
||||
private _cssFileName: string;
|
||||
private _mergedCssSelectors: RuleSet[];
|
||||
private _localCssSelectors: RuleSet[] = [];
|
||||
@ -154,25 +154,26 @@ export class StyleScope {
|
||||
}
|
||||
|
||||
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 {
|
||||
this._css = this._css && append ? this._css + cssString : cssString;
|
||||
if (cssFileName) {
|
||||
this._cssFileName = cssFileName;
|
||||
}
|
||||
|
||||
private setCss(cssString: string, cssFileName?): void {
|
||||
this._css = cssString;
|
||||
this._reset();
|
||||
this._localCssSelectors = createSelectorsFromCss(this._css, cssFileName, this._keyframes);
|
||||
this._localCssSelectorVersion++;
|
||||
this.ensureSelectors();
|
||||
}
|
||||
|
||||
const parsedSelectors = createSelectorsFromCss(this._css, cssFileName, this._keyframes);
|
||||
|
||||
if (append) {
|
||||
this._localCssSelectors.push.apply(this._localCssSelectors, parsedSelectors);
|
||||
} else {
|
||||
this._localCssSelectors = parsedSelectors;
|
||||
private appendCss(cssString: string, cssFileName?): void {
|
||||
if (!cssString) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._css = this._css + cssString;
|
||||
this._reset();
|
||||
let parsedCssSelectors = createSelectorsFromCss(cssString, cssFileName, this._keyframes);
|
||||
this._localCssSelectors.push.apply(this._localCssSelectors, parsedCssSelectors);
|
||||
this._localCssSelectorVersion++;
|
||||
this.ensureSelectors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user