Skip to content

Commit

Permalink
perf: don't manipulate the classes list on arranged
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 9, 2021
1 parent 5f0aed5 commit e820c2b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/Uno.UI/WasmScripts/Uno.UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ var Uno;
element.setAttribute("XamlType", uiElementRegistration.typeName);
element.setAttribute("XamlHandle", this.handleToString(contentDefinition.handle));
if (uiElementRegistration.isFrameworkElement) {
this.setAsUnarranged(element);
this.setAsUnarranged(element, true);
}
if (element.hasOwnProperty("tabindex")) {
element["tabindex"] = contentDefinition.isFocusable ? 0 : -1;
Expand Down Expand Up @@ -818,10 +818,16 @@ var Uno;
return true;
}
setAsArranged(element) {
element.classList.remove(WindowManager.unoUnarrangedClassName);
if (!element._unoIsArranged) {
element._unoIsArranged = true;
element.classList.remove(WindowManager.unoUnarrangedClassName);
}
}
setAsUnarranged(element) {
element.classList.add(WindowManager.unoUnarrangedClassName);
setAsUnarranged(element, force = false) {
if (element._unoIsArranged || force) {
element._unoIsArranged = false;
element.classList.add(WindowManager.unoUnarrangedClassName);
}
}
/**
* Sets the transform matrix of an element
Expand Down
14 changes: 10 additions & 4 deletions src/Uno.UI/ts/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace Uno.UI {
element.setAttribute("XamlType", uiElementRegistration.typeName);
element.setAttribute("XamlHandle", this.handleToString(contentDefinition.handle));
if (uiElementRegistration.isFrameworkElement) {
this.setAsUnarranged(element);
this.setAsUnarranged(element, true);
}
if (element.hasOwnProperty("tabindex")) {
(element as any)["tabindex"] = contentDefinition.isFocusable ? 0 : -1;
Expand Down Expand Up @@ -666,11 +666,17 @@ namespace Uno.UI {

private setAsArranged(element: HTMLElement | SVGElement) {

element.classList.remove(WindowManager.unoUnarrangedClassName);
if (!(<any>element)._unoIsArranged) {
(<any>element)._unoIsArranged = true;
element.classList.remove(WindowManager.unoUnarrangedClassName);
}
}

private setAsUnarranged(element: HTMLElement | SVGElement) {
element.classList.add(WindowManager.unoUnarrangedClassName);
private setAsUnarranged(element: HTMLElement | SVGElement, force: boolean = false) {
if ((<any>element)._unoIsArranged || force) {
(<any>element)._unoIsArranged = false;
element.classList.add(WindowManager.unoUnarrangedClassName);
}
}

/**
Expand Down

0 comments on commit e820c2b

Please sign in to comment.