Repository navigation
Replace selector-observer - #5886
Conversation
selector-observer (where constructor was used)selector-observer
|
Already found two pretty serious limitations:
I think the "freedom" that an extremely-lightweight solution grants us is completely taken away from the fact that any overlapping selectors may at any time just break. We could be careful about this, but there's no way we'd actually be successful at this. A 1-character bugfix could break another feature and we wouldn't know until much later. |
fregante
left a comment
There was a problem hiding this comment.
I found a solution to the multiple-observers problem and also the compatibility with any other native animations:
- it doesn't matter what animation is triggered, the observer just needs any animation to start in order to find the element
However… I just realized that there's still another problem with this solution:
- an animation starts on an element
- the selector isn't matched yet
- a class is added
- the selector is matched
- the animation doesn't start again
I don’t think there's a solution here. However I slice it, there can only be one animation/trigger per element
|
Ok I found another solution for the issue I described, which also covers the possible issue I mentioned earlier:
In short, like before, once the element is seen, it's marked as seen via The only situation where this workaround fails is on elements that have a permanent/native |
|
I will merge this PR this weekend, reviews welcome before then. |
🎉 This is no longer accepted:
```
const cb = (a: HTMLParagraphElement) => {
console.log(a);
}
observe('a', cb);
```
| animation: 1ms ${animation}; | ||
| } | ||
| `); | ||
| getTag().append(rule); |
There was a problem hiding this comment.
Here's the style tag update in action, as I navigate GitHub:
Screen.Recording.4.mov
Brilliant! I think it's an acceptable cost having to do
Agreed, I don't think any of our targets are using animations. In the future we can also use |
selector-observerto addAbortSignal, better types, etc #5874Not tested.
If the WeakSet doesn't match existing elements, the function will also need to attach a temporary class because I removed our custom
:not(rgh-etc)selectors