Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard observer value wrong with reentrant change #5475

Closed
kevinpschaaf opened this issue Jan 31, 2019 · 0 comments
Closed

Wildcard observer value wrong with reentrant change #5475

kevinpschaaf opened this issue Jan 31, 2019 · 0 comments
Assignees

Comments

@kevinpschaaf
Copy link
Member

Description

When a wildcard observer is queued to run, and a different batched property re-sets a dependency to the observer, the nested call to the observer returns the correct information, but the initially queued observer runs with a stale value in the info argument.

Live Demo

Setup: The trigger dependency causes computeArray to be run with an uninitialized size (defaults to 0); at this point the arrayChanged observer is queued to run, but before it does the trigger observer runs and sets size to 1. This causes a nested invocation of computeArray and arrayChanged to be run first (with the correct info information reflecting the new array size of 1). However, when the processing unrolls back to the initially queued invocation of arrayChanged, it runs with stale info information.

3.x: https://jsbin.com/babeyaz/1/edit?html,console,output (wrong)
1.x: https://jsbin.com/vojode/edit?html,console,output (correct)

Expected Results

info.value.length always matches this.array.length at the time the observer runs.

Actual Results

The initial observer invocation (which runs last, due to a re-entrant change after it was enqueued) returns info.value.length == 0 while this.array.length == 1.

Note that in 3.x, the observer runs twice, while in 1.x it only runs once. This is expected, since in 1.x the initial call to computeArray is aborted because of the "undefined" rule (the size argument is yet undefined); however in 2.x comptueArray runs first due to trigger, and subsequently due to size. That is WAI, however the info should always reflect the current state of the world

Browsers Affected

All

Versions

  • Polymer: v3.x, v2.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant