codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
13.03k stars 2.27k forks source link

Struggling with duplicate lit-html #5079

Closed tpluscode closed 3 years ago

tpluscode commented 3 years ago

🐛 bug report

Preflight Checklist

Description of the problem

I'm trying to create a sandbox for my custom elements based on lit-element/lit-html. When running they don't render correctly, but in a ways which typically indicates duplicate resolution of lit-html.

I found similar report #1257 but inspecting the manager did not reveal any duplication. At least I did not notice it.

To Reproduce

Check my sandbox linked below.

There are 3 lines to notice in index.js

import "@hydrofoil/shaperone-wc/ShaperoneForm";
import * as MaterialRenderStrategy from "@hydrofoil/shaperone-wc-material/renderer";
import * as vaadinComponents from "@hydrofoil/shaperone-wc-vaadin/components";

Comment out the latter two and the core element renders. As soon as either @hydrofoil/shaperone-wc-material or @hydrofoil/shaperone-wc-vaadin is imported, the page breaks.

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox dunno
Browser Safari, Chrome, no matter
Operating System Mac OS
sannek commented 3 years ago

Thanks for your report - We'll have a look to see what is going on and get back to you.

SaraVieira commented 3 years ago

Hey!

Sorry, I do not have a lot of experience with Web Components,

Can you please tell me what I am supposed to see in this sandbox: https://codesandbox.io/s/quizzical-buck-edtcx

I tried deleting the lines you mentioned but get the same thing :/

tpluscode commented 3 years ago

Sorry @SaraVieira, I think the description was not accurate. Change the code as shown below and a plain form with a single field will appear

import "@hydrofoil/shaperone-wc/ShaperoneForm";
// import { renderer, components } from "@hydrofoil/shaperone-wc/configure";
// import * as MaterialRenderStrategy from "@hydrofoil/shaperone-wc-material/renderer";
// import * as vaadinComponents from "@hydrofoil/shaperone-wc-vaadin/components";
import { dataset } from "@rdf-esm/dataset";
import clownface from "clownface";
import { NodeShapeMixin } from "@rdfine/shacl";
import { ShapeBundle } from "@rdfine/shacl/bundles";
import { schema } from "@tpluscode/rdf-ns-builders";
import RdfResource from "@tpluscode/rdfine";

RdfResource.factory.addMixin(...ShapeBundle);

// renderer.setStrategy(MaterialRenderStrategy);
// components.pushComponents(vaadinComponents);

const resource = clownface({ dataset: dataset() }).blankNode();
const shape = new NodeShapeMixin.Class(
  clownface({ dataset: dataset() }).blankNode(),
  {
    property: [
      {
        path: schema.name,
        name: "Name",
        minCount: 1
      }
    ]
  }
);
console.log(resource);
const form = document.querySelector("shaperone-form");
form.shapes = shape.pointer;
form.resource = resource;
SaraVieira commented 3 years ago

Thank you!

I think I figured out what the underlying error is: https://codesandbox.io/s/quizzical-buck-edtcx?file=/index.js

Will take a look with @CompuIves tomorrow

Thank you for your help

tpluscode commented 3 years ago

Any updates @SaraVieira ?

CompuIves commented 3 years ago

I've committed a fix, will test it some more before merging!