question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

you are still relying on mwc elementes to be defined globally by HA

See original GitHub issue

The changes you made to start using the scoped custom element registry (according to https://developers.home-assistant.io/blog/2022/02/18/paper-elements/ and https://developers.home-assistant.io/blog/2020/10/02/lazymoreinfo/#what-about-external-elements) are not bulletproof just yet. The idea is that your card relies entirely on its own bundled elements in order to work and here it is violated.

Let’s take for example the mwc-list-item custom element you added. This element, internally, renders mwc-ripple. Since you didn’t define your custom class as a ScopedRegistryHost, the internal mwc-ripple element, will only be rendered if the global registry defines it (which is currently being done by HA). If HA suddenly drops the support for MWC, the element will not be rendered properly. This happens because ScopedRegistryHost is not recursive, and only applies to the elements directly rendered by it.

The solution I applied in other cards (https://github.com/artem-sedykh/mini-climate-card/pull/67 for example), is to define each custom element as ScopedRegistryHost as well while setting its used elements as well (https://github.com/regevbr/mini-climate-card/blob/f61364816c5667370eebc5a44168713e5c36ea02/src/components/mwc/list-item.js#L7-L17) If you are willing, I don’t mind drafting a PR.

Another issue, that also relates to how HA sees custom cards - Custom Cards using the elements used in the Home Assistant Frontend have never been supported (taken verbatim from the above-mentioned blog posts). So it seems that using `ha-card- here should also be removed.

@iantrich I would appreciate your input on the matter (I hope I was clear enough)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
regevbrcommented, Mar 10, 2022

The idea is that the custom card only has 1 custom registry, not every element. By passing the registry of the host down we make sure they all share the same registry.

There really isn’t much magic going on, and by creating a mixin like I did here #52 (comment) I don’t think it is verbose at all?

I see your point, but you are creating a “global” registry just for the card. There can still be conflicts between elements when you do that, if, for example, you use a couple of libraries. I prefer the encapsulations of my method, but they both work, so it is just a question of style.

0reactions
bramkragtencommented, Mar 10, 2022

The idea is that the custom card only has 1 custom registry, not every element. By passing the registry of the host down we make sure they all share the same registry.

There really isn’t much magic going on, and by creating a mixin like I did here https://github.com/custom-cards/boilerplate-card/issues/52#issuecomment-1064009326 I don’t think it is verbose at all?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Analyzing and Synthesizing the Rule - Berkeley Law
Breaking the rule into elements makes it easier for you to apply the rule in a given set of circumstances. Example: Plaintiff collects...
Read more >
Teacher Instructions
Before falling off the yacht, Rainsford believes that hunting is merely a sport, a great sport, and that if you show compassion for...
Read more >
Full BeneFits - of a Flexible Spending Account with a Debit Card
A Flexible Spending Account (FSA) allows you to set aside money, on a pre-tax basis, to pay for IRS approved out-of-pocket expenses.
Read more >
Chapter 4 — Global Warming of 1.5 ºC - IPCC
The global response to warming of 1.5°C comprises transitions in land and ecosystem, energy, urban and infrastructure, and industrial systems.
Read more >
FDM 450 Examples
For example, a sector mutual fund meets the definition of an EIF. ... Do not rely on financial statements that show only what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found