Giter VIP home page Giter VIP logo

Comments (9)

zerodevx avatar zerodevx commented on June 14, 2024

Could you paste the HTML code you're using?

from zero-md.

jonmann20 avatar jonmann20 commented on June 14, 2024
import 'zero-md';
class Foo extends LitElement {
  static properties = {item: {type: Object}};

  render() {
    return html`
        ${this.item?.changelog && this.item.changelog !== '' ? html`
            <zero-md @zero-md-rendered="${() => this.dispatchEvent(new Event('notifyResize'))}">
                <script type="text/markdown">${this.item.changelog}</script>
            </zero-md>
        ` : ''}
    `;
  }
}

from zero-md.

zerodevx avatar zerodevx commented on June 14, 2024

The script is added to document.head and loaded, but may be some race condition.

What is being added into <head>?

Also would be great in general to have this be a local file as I currently have to allow all of cdn.jsdelivr.net for this.

It's possible to load dependencies locally. If you can give more details about your code and setup maybe I can help.

Lastly, you should probably import the <zero-md> class, then define the customElement:

import ZeroMd from 'zero-md'

customeElements.define('zero-md', ZeroMd)

class Foo extends LitElement {
  ...
}

from zero-md.

jonmann20 avatar jonmann20 commented on June 14, 2024
<script src="https://cdn.jsdelivr.net/gh/PrismJS/prism@1/prism.min.js" data-manual=""></script>
<script src="https://cdn.jsdelivr.net/gh/PrismJS/prism@1/plugins/autoloader/prism-autoloader.min.js"></script>

are added to head.

I'm using rollup/nodeResolve to bundle for production. Just imports (w/nodeResolve server) for dev.

I'm using the component in multiple places in the application so that would result in a duplicate registry error.

from zero-md.

jonmann20 avatar jonmann20 commented on June 14, 2024

Also seeing double rendering (maybe) related to this. Calling .refreshContent() prints this error.

from zero-md.

jonmann20 avatar jonmann20 commented on June 14, 2024

FYI, rolling back to v2.1.1 fixed the double rendering issue so that is likely something separate from Prism.

from zero-md.

zerodevx avatar zerodevx commented on June 14, 2024

Thanks for investigating. I think some of the v2.2.0 code re dynamic content refresh needs to be refactored. I'll get to clearing this backlog soon. 🙏

Will keep you updated in this thread.

from zero-md.

zerodevx avatar zerodevx commented on June 14, 2024

Hi, FYI there's a new v2.3.0 release - are you still encountering issues with this?

from zero-md.

jonmann20 avatar jonmann20 commented on June 14, 2024

Thanks, yes this seems to have resolved the double loading issue. I will close this for now and keep an eye out for the previously mentioned prism issue.

from zero-md.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.