Giter VIP home page Giter VIP logo

Comments (7)

WebReflection avatar WebReflection commented on September 25, 2024 5

It was a uparser issue which has now been fixed (and covered).

Apologies for the inconvenient.

from uhtml.

vimtaai avatar vimtaai commented on September 25, 2024 1

We ran into the same issue. The html.node function does not return an HTMLElement instance in our codebase when we import it from NPM and bundle it with webpack. However, if we load the package from a CDN, it does. The version is 3.0.0 in both cases.

from uhtml.

vimtaai avatar vimtaai commented on September 25, 2024 1

We did a little more deep-dive:
It seems like, that if the template for the html.node function starts with an empty line it will return a #document-fragment instead of an HTMLElement.

Please check out this code to reproduce:

import { html } from "https://cdn.jsdelivr.net/npm/[email protected]/esm.js";

const elementA = html.node`<div>foo</div>`;
const elementB = html.node`
  <div>bar</div>
`;

console.log(elementA instanceof HTMLElement);
console.log(elementB instanceof HTMLElement);

from uhtml.

vimtaai avatar vimtaai commented on September 25, 2024 1

It has nothing to do with importing from NPM or a CDN, it's just that we had a different template in our production code.

from uhtml.

dbauszus-glx avatar dbauszus-glx commented on September 25, 2024 1

I can confirm this. I just double checked my production code.

Unfortunately we use the empty line a lot at the beginning of tagged templates. Following syntax is quite common in our project:

      mapp.utils.render(mapview.attribution.target,
        mapp.utils.html`${Object.entries(o)
          .map(entry => mapp.utils.html`
              <a class="background-fade" target="_blank" href="${entry[1]}">${entry[0]}`)}`)

from uhtml.

vimtaai avatar vimtaai commented on September 25, 2024 1

Thanks for the quick fix, @WebReflection <3

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

So … the bug is about code that works as expected? I’ve no idea how to help here.

The parser is different and it might be the culprit … try older uparser with uhtml 3 or just stick with uhtml 2 until you understand what’s failing and how I can reproduce it?

from uhtml.

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.