Explore using `selector-observer` to run features
See original GitHub issueGitHub uses selector-observer to enable logic on simple classes, which is why adding or removing classes like .js-fit-content
will enable or disable their features.
It’s built around MutationObserver
with various optimizations on top of it. Its performance might not be super (https://bugzilla.mozilla.org/show_bug.cgi?id=1422522) but it seems to work well enough for GitHub.
It’s worth investigating if anyone has time, it would elegantly solve issues around dynamic content and all the specific listeners we have.
I think observe
calls would go inside each feature’s init
, which could only be called once.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top Results From Across the Web
josh/selector-observer: Allows you to monitor DOM ... - GitHub
selector -observer allows you to monitor DOM elements that match a CSS selector. Rather than imperatively querying the DOM, register an observer for...
Read more >Any way to use MutationObserver to watch for insertions of ...
One option is to use the Mutation Summary. Their API is pretty simple: var observer = new MutationSummary({ callback: function (changes) ...
Read more >An Explanation of How the Intersection Observer Watches
This provides a way to identify which observer is in play in case a target is tied to multiple observers. The third section...
Read more >A journey into NgRx Selectors - Angular inDepth
This article dives deep into NgRx selectors and will help you understand what role that play in NgRx architecture and how they help...
Read more >Swift Selectors: Everything You Need to Know | Waldo Blog
So, in this article, we'll explore Objective-c selectors. You'll learn what they are and how to use them in Swift.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yakov116 if you also want to look into any other features that use
selector-observer
but don’t have this class, please send a PR for thatI confirmed the bug and found a workaround:
:not(.rgh-this-feature)
and we add the class right away,selector-observer
will no longer call theadd
method because the original selector no longer applies. This avoids the loop.We almost always do that already, but #3517 didn’t because it didn’t seem necessary.
@kidonng you can resubmit #3517 with the workaround described#3531 already exists 👍linkify-code
, which is the heaviest feature making use ofselector-observer