[feat]: Add option for observing external mutations#10
Closed
arielsalminen wants to merge 78 commits intomainfrom
Closed
[feat]: Add option for observing external mutations#10arielsalminen wants to merge 78 commits intomainfrom
arielsalminen wants to merge 78 commits intomainfrom
Conversation
3 tasks
3 tasks
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
- @elenajs/bundler@1.0.0 - @elenajs/cli@1.0.0 - @elenajs/components@1.0.0 - @elenajs/core@1.0.0 - @elenajs/eslint-config@1.0.3 - @elenajs/mcp@1.0.0-alpha.10 - @elenajs/plugin-cem-define@1.0.0 - @elenajs/plugin-cem-prop@1.0.0 - @elenajs/plugin-cem-tag@1.0.0 - @elenajs/plugin-cem-typescript@1.0.0 - @elenajs/plugin-rollup-css@1.0.0 - @elenajs/prettier-config@1.0.2 - @elenajs/ssr@1.0.0-alpha.10
✅ Deploy Preview for elenajs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft PR addresses #9 by adding an opt-in
observebehavior for Primitive Components.While this improves the framework usage ergonomics in certain scenarios, I don’t think if it’s worth it to actually ship given the
performance implications andcomplexity it adds and new edge cases it introduces. Primitive Components also default to Light DOM for progressive enhancement, which is the root cause for this limitation.This option would only make a difference in this scenario:
render()method.textContentinstead of the built-intextprop.Right now, you have to do this when you want to dynamically update text of a Primitive Component after initial render:
With the proposed changes, you could set
static observe = trueand also do:In a framework world, this would enable the following without having to use the
textprop:Currently, we document the limitation in at least these locations:
While I am not yet convinced this should become a part of the core library, we’ll let this discussion evolve.
The fundamental tension is that this feature tries to undo what frameworks do to Light DOM. The existing
textprop approach documented in the gotchas is more reliable than the one introduced here because it works WITH Elena’s prop system rather than trying to reverse-engineer external DOM mutations.This would also probably introduce issue with Angular + Zone.js that monkey-patches
MutationObserver. When Elena's observer callback in this version fires, Zone.js would see it as an async task and trigger a new change detection cycle. If that cycle re-evaluates a template binding and re-setstextContentto the same value, you could get an oscillation loop.Another options is also perhaps addressing this with a better/clearer documentation instead? There is also the existing, undocumented possibility, that you can create a framework wrapper component that passes the children to the text prop instead.
Edit: The performance part has been improved and the tests no longer show a difference neither in initial rendering speed of up to 1000x Elena components on page or re-renders based on prop changes. But there is still the fact that when you enable
observefor a component that gets repeated thousands of times in a view, this could create performance concerns.