rootEnginear / svelte-action-motionone

Unofficial Svelte Action for Motion One animation library
https://www.npmjs.com/package/@rootenginear/svelte-action-motionone
MIT License
10 stars 0 forks source link

`&` behavior is WRONG! #2

Closed rootEnginear closed 1 week ago

rootEnginear commented 1 month ago

Problem

After applied to my project, I've found out that this function

https://github.com/rootEnginear/svelte-action-motionone/blob/ac963c726ad058a47e30564911cda847e69c490d/src/lib/utils/selector.ts#L3-L8

is so SO WRONG! — let's look at it from case by case.

&>* (child combinator)

In this case, it will be evaluated to { isSelf: false, selector: "*" } which is WRONG! Because * means EVERYTHING, not only the direct children.

& *, &+*, &~* (descendant, next-sibling, subsequent-sibling combinator)

In this case, it will be passed to Motion (or select directly from document in getNodeElement) since it's neither a single & nor pass the /^\s*&\s*>/, hence the result from parseStringSelector is { isSelf: false, selector: "& *" }

The (easy) solution is just make the behavior correct and call it a day, for now.

rootEnginear commented 1 week ago

Fixed in v0.5.0!