lit / lit-element

LEGACY REPO. This repository is for maintenance of the legacy LitElement library. The LitElement base class is now part of the Lit library, which is developed in the lit monorepo.
https://lit-element.polymer-project.org
BSD 3-Clause "New" or "Revised" License
4.49k stars 318 forks source link

Bug: @query broken with cache = true and babel decorators #1142

Closed bschlenk closed 3 years ago

bschlenk commented 3 years ago

When using @query with cache: true, it generates the key based on the passed in name - but name only exists for legacy decorators. This results in the key always being __undefined, so multiple uses of @query in one component result in all of them using using the same cached value. See the code here. This should probably be replaced with:

const prop = name === undefined ? protoOrDescriptor.key : name;
const key = typeof prop === 'symbol' ? Symbol() : `__${prop}`;

If this looks like a good solution, I can send a PR.