Skip to content

[labs/context] @contextProvided and @contextProvider decorators pollute base class when sub-classing #3296

@christophe-g

Description

@christophe-g

Which package(s) are affected?

Context (@lit-labs/context)

Description

Using decorators to declare context in a sub-class adds it to the base class.

class Base extends LitElement {
	@contextProvided({context: simpleContext, subscribe: true})
	@property({type: Number})
	public value = 0;
}

class Ext extends Base {
	@contextProvided({context: simpleContext, subscribe: true})
	@property({type: Number})
	public valueExt = 1;
}

Any instance of Base will have 2 controllers, its own AND the one declared in the exended class.

Expected behavior: It should only have one controller.

Reproduction

See https://lit.dev/playground/?linkId=8223273#gist=4875267ed996afc7bad538e17fe80907

Workaround

Do not use context decorators when sub-classing, but this is not really a workaround

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

lit: 2.3.1; @lit-labs/context: 0.1.3

Browser/OS/Node environment

Chrome stable latest, linux mint.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions