andreasbm / weightless

High-quality web components with a small footprint
MIT License
377 stars 31 forks source link

snackbar from template rendering issue #74

Open caliny97 opened 5 years ago

caliny97 commented 5 years ago

Having a difficult time getting the snackbar from a template to work. Tried the code from the demo and a very simple template and it always rendered the same. Seems like the template content is not parsed.

image

tionkje commented 5 years ago

I have had a similar issue. With me it was because i was using rollup and a different version of lit-html. Internally it uses instanceof a lit-html class and rollup renamed them to prevent clashes.

Just make sure yout lit-element/lit-html versions are the same as in weightless.

caliny97 commented 5 years ago

I have had a similar issue. With me it was because i was using rollup and a different version of lit-html. Internally it uses instanceof a lit-html class and rollup renamed them to prevent clashes.

Just make sure yout lit-element/lit-html versions are the same as in weightless.

Made sure there is only one version of lit-element/lit-html being used but the issue still remains. My project doesn't use roll-up or webpack, it uses boiler code from PWA. Thanks

caliny97 commented 5 years ago

@andreasbm - any ideas about this issue? , I tried stepping thru but couldn't find the cause. Thanks

caliny97 commented 5 years ago

After digging more into this, i found the issue. The if/else condition "value instanceof TemplateResult" is skipped, event thought value is clearly an instance of TemplateResult and it just defaults to commit the value as is. I guess the issue lies at lit-html , my code is running as ES modules from polymer cli, not babel or rollup. Any ideas how to resolve this? Thanks

image

caliny97 commented 5 years ago

Finally resolved this. It turns out that weightless npm install includes its own version of lit-html, the if condition was skipped because the instance of TemplateResult was from the weightless copy of lit-html. For now i just deleted node_modules from node_modules/weightless. @andreasbm any reason for including a copy of lit-html? Thanks