Ensure firstUpdated
is always called when the element first updated
#173
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.
Reference Issue
Fix #172
As described in #172, the
firstUpdated
lifecycle method is not always called.The problem was in the
_validate()
method oflib/update-element.ts
:If
shouldUpdated
return false, the element is still marked as updated in_markUpdated
, but the element isn't updated.So if the first time the element tries to update
shouldUpdated
return false, the element is marked as updated. Then when the element is really going to be updated, the checkconst needsFirstUpdate = !(this._updateState & STATE_HAS_UPDATED);
is false, andfirstUpdated
isn't called.I have added a new test case to test this problem, and the version 0.6.0-dev.6 doesn't pass it.
Then I have modified
lib/update-element.ts
with a new_markNotUpdated()
method that is called whenshouldUpdate
returns false, and that doesn't mark the element as updated.With that fix
firstUpdated
is always called the first time and all the other tests are still valid.