diff --git a/CHANGELOG.md b/CHANGELOG.md index 5493b7192..b26f74865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [8.0.8](https://github.com/NativeScript/NativeScript/compare/8.0.7-core...8.0.8) (2021-06-15) + + +### Bug Fixes + +* stop leaking style scopes ([#9444](https://github.com/NativeScript/NativeScript/issues/9444)) ([b8d8110](https://github.com/NativeScript/NativeScript/commit/b8d8110994ecb5a882e89ae10e7b13070ae4d709)), closes [#9311](https://github.com/NativeScript/NativeScript/issues/9311) +* **android:** accessibilityIdentifier ([#9432](https://github.com/NativeScript/NativeScript/issues/9432)) ([9f582ba](https://github.com/NativeScript/NativeScript/commit/9f582ba168dd6f4366e2591a9fed10e1c2443ca4)) + + + ## [8.0.7](https://github.com/NativeScript/NativeScript/compare/8.0.6-core...8.0.7) (2021-06-02) diff --git a/package.json b/package.json index 1d7ad7806..6481fc558 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "8.0.7", + "version": "8.0.8", "license": "MIT", "config": { "npm_alias": "npm" diff --git a/packages/core/package.json b/packages/core/package.json index 04fbf9661..3d330ea43 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.", - "version": "8.0.7", + "version": "8.0.8", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/ui/styling/css-selector/index.ts b/packages/core/ui/styling/css-selector/index.ts index 717adbdaa..6e0cdd75c 100644 --- a/packages/core/ui/styling/css-selector/index.ts +++ b/packages/core/ui/styling/css-selector/index.ts @@ -501,6 +501,7 @@ export namespace Selector { export class RuleSet { tag: string | number; + scopedTag: string; constructor(public selectors: SelectorCore[], public declarations: Declaration[]) { this.selectors.forEach((sel) => (sel.ruleset = this)); } diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index 62ec081f6..20dc31540 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -74,6 +74,8 @@ export function mergeCssSelectors(): void { let applicationCssSelectors: RuleSet[] = []; let applicationCssSelectorVersion = 0; let applicationSelectors: RuleSet[] = []; +let tagToScopeTag: Map = new Map(); +let currentScopeTag: string = null; const applicationAdditionalSelectors: RuleSet[] = []; const applicationKeyframes: any = {}; const animationsSymbol = Symbol('animations'); @@ -313,12 +315,17 @@ export function removeTaggedAdditionalCSS(tag: string | number): boolean { export function addTaggedAdditionalCSS(cssText: string, tag?: string | number): boolean { const parsed: RuleSet[] = CSSSource.fromDetect(cssText, applicationKeyframes, undefined).selectors; + let tagScope = currentScopeTag || (tag && tagToScopeTag.has(tag) && tagToScopeTag.get(tag)) || null; + if (tagScope && tag) { + tagToScopeTag.set(tag, tagScope); + } let changed = false; if (parsed && parsed.length) { changed = true; - if (tag != null) { + if (tag != null || tagScope != null) { for (let i = 0; i < parsed.length; i++) { parsed[i].tag = tag; + parsed[i].scopedTag = tagScope; } } applicationAdditionalSelectors.push(...parsed); @@ -687,6 +694,7 @@ export class StyleScope { private _localCssSelectorsAppliedVersion = 0; private _applicationCssSelectorsAppliedVersion = 0; private _keyframes = new Map(); + private _cssFiles: string[] = []; get css(): string { return this._css; @@ -708,8 +716,11 @@ export class StyleScope { if (!cssFileName) { return; } + this._cssFiles.push(cssFileName); + currentScopeTag = cssFileName; const cssSelectors = CSSSource.fromURI(cssFileName, this._keyframes); + currentScopeTag = null; this._css = cssSelectors.source; this._localCssSelectors = cssSelectors.selectors; this._localCssSelectorVersion++; @@ -731,8 +742,13 @@ export class StyleScope { if (!cssString && !cssFileName) { return; } + if (cssFileName) { + this._cssFiles.push(cssFileName); + currentScopeTag = cssFileName; + } const parsedCssSelectors = cssString ? CSSSource.fromSource(cssString, this._keyframes, cssFileName) : CSSSource.fromURI(cssFileName, this._keyframes); + currentScopeTag = null; this._css = this._css + parsedCssSelectors.source; this._localCssSelectors.push(...parsedCssSelectors.selectors); this._localCssSelectorVersion++; @@ -776,7 +792,7 @@ export class StyleScope { @profile private _createSelectors() { const toMerge: RuleSet[][] = []; - toMerge.push(applicationCssSelectors); + toMerge.push(applicationCssSelectors.filter((v) => !v.scopedTag || this._cssFiles.indexOf(v.scopedTag) >= 0)); this._applicationCssSelectorsAppliedVersion = applicationCssSelectorVersion; toMerge.push(this._localCssSelectors); this._localCssSelectorsAppliedVersion = this._localCssSelectorVersion;