Repository navigation
Ensure user accessor is never overridden - #359
Merged
Merged
Conversation
Fixes #286. * Only processes properties expicitly defined on the class. This avoids double work since properties are inherited. * We now also avoid creating a property if the property already exists anywhere in the element's prototype chain. Previously, this was an `ownProperty` check. * This also removes the optimization of taking the property options from the closure where the property is defined. This allows subclasses to redefine property options without needing to redefine the accessor. * Finally, also removes the private `_requestPropertyUpdate` which would be superfluous with this change.
sorvell
pushed a commit
that referenced
this pull request
Dec 15, 2018
* uses `JSCompiler_renameProperty` where literal names are needed instead of using `@export` * The private `_classProperties` is no longer created by default. Instead `_ensureClassProperties` was added and is called to make sure that the specific class has its own storage for class properties. * Adds a test that ensure a subclass cannot alter a superclass. The condition tested here would only fail after merging #359. * optimization: ensures `LitElement` is marked as `finalized` so that it does not ever try to finalize.
sorvell
commented
Dec 15, 2018
kevinpschaaf
approved these changes
Dec 15, 2018
Member
|
Won't merge until Sauce service incident is resolved and tests pass. |
kevinpschaaf
pushed a commit
that referenced
this pull request
Jan 10, 2019
* Fully support Closure compiler including ADVANCED_OPTIMIZATIONS Currently, compiling lit-element with the Closure compiler results in a clean build but a number of hard JS errors due to a few issues: - static methods being collapsed (i.e. removed entirely) - Object.hasOwnPropertyName() looking for static properties that have been rewritten by the compiler - static property initializers not being run when @exported The last issue is a compiler bug being tracked internally, but all three need to be worked around before this will compile and run cleanly. This includes all of the necessary fixes, including addressing the last issue by moving the Object.hasOwnPropertyName('_classProperties') check to _finalize(). This is necessary to ensure that _classProperties is defined before it's iterated in observedProperties on an element that has no properties. Another option for making _finalized and _classProperties public would be to move to checking this._finalized and this._classProperties and not needing to access them by name - I thought that was out of scope for this but would be happy to change to that style if reviewers prefer. * Make compatible with closure compiler * uses `JSCompiler_renameProperty` where literal names are needed instead of using `@export` * The private `_classProperties` is no longer created by default. Instead `_ensureClassProperties` was added and is called to make sure that the specific class has its own storage for class properties. * Adds a test that ensure a subclass cannot alter a superclass. The condition tested here would only fail after merging #359. * optimization: ensures `LitElement` is marked as `finalized` so that it does not ever try to finalize. * Format. * Use JSCompiler_renameProperty for `properties` * Minor updates based on review feedback. * Remove @nocollapse from static fields with no initializer
6 tasks done
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.
Fixes #286.
When a property is declared in
propertiesor via thepropertydecorator, we will always generate an accessor on the current class that enqueues an update viarequestUpdateHowever, if an accessor already existed on the class prototype chain, that accessor will be effectively super'ed to for both
setandget(while still ensuring an update is enqueued); this is achieved by capturing the existing accessor and calling them from the generated accessorThis also removes the optimization of taking the property options from the closure where the property is defined. This allows subclasses to redefine property options without needing to redefine the accessor.
Finally, also removes the private
_requestPropertyUpdatewhich would be superfluous with this change.