Conversation
hopsoft
approved these changes
Aug 26, 2022
Contributor
hopsoft
left a comment
There was a problem hiding this comment.
I think we're ok to skip the deprecation warning as it's not a breaking change in the classic sense. Folks that use this feature may have some confusion, but like you noted... this is a major version bump.
I'm ok with using missing for the custom element, but more consistency with the JavaScript options might be nice. Not a hill I'd die on though.
LGTM
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.
Here's a pass at customizable missing element warnings. I'm not attached to my approach; feel free to suggest different variable names, different attribute names, changes to the behaviour of the different modes.
I should also say that it occurred to me only as I was typing this up that perhaps this is actually the wrong approach; instead of specifically addressing missing elements, perhaps it would be better to implement a
debugconcept that would allow the developer to make decisions for all errors. There are lots of warnings etc in the codebase that have nothing to do with missing elements. Opinions, please!After deliberation, I took Marco's idea to have multiple strategies and ran with it. I figure that we can always pull these extra options out if we don't want them.
CableReady.initializenow supports anonMissingElementoption which sets a global value. As always, it defaults to warnings (warn) but also supportsignore,event,exception. It will warn if you pass an invalid option, falling back towarn.eventraises acable-ready:missing-elementevent ondocument.exceptionthrows an exception.The
emitMissingElementWarningsoption onperformandperformAsynchas been removed in favor ofonMissingElement. It's a major version bump, after all. A value provided overrides the global value.We could optionally test for
emitMissingElementWarnings: false, issue a deprecation warning and setonMissingElement: 'ignore', but it's not implemented at this time. Opinions, please!Finally, the
stream_fromweb component checks for amissingattribute and falls back to the global setting. The WC supportswarn,ignoreandevent, but notexception. This is because there's no way for a developer tocatchan exception raised by the WC.Again, I'm happy to change the attribute. I started with short and simple, because
missing-elementrequires using double-quotes which I find ugly: