Skip to content

Commit

Permalink
Major performance fix for certain css selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
somebee committed Jan 12, 2024
1 parent c10ef46 commit 8a3ae98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/imba/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

## Unreleased

* Major performance fix for certain css selectors.

When using selectors like `^@hover prop:value` Imba would compile
the selector to `:is(:hover).some-class > target { prop:value }`.
The fact that `:is(:hover)` is placed before the class can cause
the browser to recalculate styles for a huge part of the document
when pointer crosses between elements.

Rewriting the compiled selector to `.some-class:is(:hover) > target`
makes this issue go away completely. If you ever use selectors like
this it is highly recommended to update.

* Fix tooling for `item isa (a or b or c)` syntax

* Fix tooling for tags inside if/else trees
* Fix tooling for tags inside

* Fix sourcemapping for tag declaration superclass

Expand Down
2 changes: 1 addition & 1 deletion packages/imba/src/compiler/selparse.imba
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {modifiers} from './theme.imba'

def addClass rule, name
# TODO check for negs as well?
rule.push({flag: name})
rule.unshift({flag: name})
# rule.classNames ||= []
# if rule.classNames.indexOf(name) == -1
# rule.classNames.push(name)
Expand Down

0 comments on commit 8a3ae98

Please sign in to comment.