Skip to content

Commit f5feddd

Browse files
committed
perf: Finalize CountryFlag optimization with cleanup and comments (#9053)
1 parent 5ae1d37 commit f5feddd

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

resources/scss/src/component/CountryFlag.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
overflow : hidden;
66
width : 100%;
77

8-
.neo-country-flag, .neo-country-placeholder {
8+
.neo-country-flag {
99
flex : none;
1010
height : 20px;
1111
margin-right: 8px;

src/component/CountryFlag.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class CountryFlag extends Component {
4242
vdom = me.vdom,
4343
[flag, text] = vdom.cn;
4444

45+
// Performance Optimization:
46+
// We maintain a persistent <img> tag in the VDOM structure to ensure a stable DOM.
47+
// Swapping tags (e.g. img <-> span) or removing nodes triggers layout thrashing
48+
// during rapid recycling (e.g. Grid scrolling).
49+
// We toggle visibility instead of structural changes.
4550
if (url) {
4651
flag.src = url;
4752
flag.style = null; // Remove visibility: hidden

0 commit comments

Comments
 (0)