Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ccb1b08

Browse filesBrowse files
committed
feature: __ONLY_ALLOW_ROOT_VARIABLES__ to make getCssVariables 10x faster
1 parent d5aa194 commit ccb1b08
Copy full SHA for ccb1b08

File tree

Expand file treeCollapse file tree

2 files changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-1
lines changed

‎packages/core/global-types.d.ts

Copy file name to clipboardExpand all lines: packages/core/global-types.d.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ declare const __ANDROID__: boolean;
135135
declare const __IOS__: boolean;
136136
declare const __VISIONOS__: boolean;
137137
declare const __ACCESSIBILITY_DEFAULT_ENABLED__: boolean;
138+
declare const __ONLY_ALLOW_ROOT_VARIABLES__: boolean;
138139

139140
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
140141
declare function clearTimeout(timeoutId: number): void;

‎packages/core/ui/core/properties/index.ts

Copy file name to clipboardExpand all lines: packages/core/ui/core/properties/index.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { ViewBase } from '../view-base';
44
import { PropertyChangeData, WrappedValue } from '../../../data/observable';
55
import { Trace } from '../../../trace';
66

7+
import { Application } from '../../../application';
8+
79
import { Style } from '../../styling/style';
810

911
import { profile } from '../../../profiling';
@@ -130,7 +132,12 @@ export function _evaluateCssVariableExpression(view: ViewBase, cssName: string,
130132
.map((v) => v.trim())
131133
.filter((v) => !!v);
132134
const cssVariableName = matched.shift();
133-
let cssVariableValue = view.style.getCssVariable(cssVariableName);
135+
let cssVariableValue;
136+
if (typeof __ONLY_ALLOW_ROOT_VARIABLES__ !== 'undefined' && __ONLY_ALLOW_ROOT_VARIABLES__ === true) {
137+
cssVariableValue = Application.getRootView().style.getCssVariable(cssVariableName);
138+
} else {
139+
cssVariableValue = view.style.getCssVariable(cssVariableName);
140+
}
134141
if (cssVariableValue === null && matched.length) {
135142
cssVariableValue = _evaluateCssVariableExpression(view, cssName, matched.join(', ')).split(',')[0];
136143
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.