WebReflection / basicHTML

A NodeJS based, standard oriented, HTML implementation.
ISC License
126 stars 10 forks source link

Broken inline CSS custom properties #56

Closed nhoizey closed 3 years ago

nhoizey commented 3 years ago

Hi, when I take the example "Good old way to init with basic selectors" from the README and add an inline custom property to the body element (with style="--foo: bar"), it is transformed in the output, with the two dashes transformed into one only.

Script:

const { Document } = require("basichtml");

const document = new Document();

// attributes
document.documentElement.setAttribute("lang", "en");

// common accessors
document.documentElement.innerHTML = `
  <head></head>
  <body style="--foo: bar"></body>
`;
document.body.textContent = "Hello basicHTML";

// basic querySelector / querySelectorAll
document
  .querySelector("head")
  .appendChild(document.createElement("title")).textContent = "HTML on NodeJS";

// toString() necessary to read, it's a Buffer
console.log(document.toString());

Output:

<!DOCTYPE html><html lang="en">
  <head><title>HTML on NodeJS</title></head>
  <body style="-foo:bar;">Hello basicHTML</body>
</html>

style="--foo: bar" is transformed into style="-foo:bar;".

WebReflection commented 3 years ago

Bummer … have you tried or hear about LinkeDOM? Is the only thing I’m using these days, close to deprecate this module, as it’s too narrow with its cope, and it fails at everything

WebReflection commented 3 years ago

P.S. it’s literally the first part of the README

nhoizey commented 3 years ago

Yes, I have heard about LinkeDOM (the day you released it!), I really want to use it instead of BasicHTML.

But I have multiple sites using BasicHTML, and npm packages depending on it used by many people, so I will unfortunately not be able to migrate right now. 😭

nhoizey commented 3 years ago

I should have said that I fully understand if you don't want to work on BasicHTML anymore, as deprecation is indeed obviously stated in the README. 👍

It looks like LinkeDOM will anyway be easier to use than BasicHTML, so I have to plan the migration ASAP.

WebReflection commented 3 years ago

I should probably put a copy/paste code here or there to explain how to have same results just better and faster via LinkeDOM

WebReflection commented 3 years ago

P.S. PR welcome, as I’m having zero time these days to deal with projects pre announced as deprecated. This should be relatively easy, but time is against me.

nhoizey commented 3 years ago

I should probably put a copy/paste code here or there to explain how to have same results just better and faster via LinkeDOM

It would be awesome.

PR welcome, as I’m having zero time these days to deal with projects pre announced as deprecated. This should be relatively easy, but time is against me.

I will try to move to LinkeDOM first, but if I'm not able to do so, I'll try to find a fix for BasicHTML. But last time I checked the code, I didn't understand much… 🙁

WebReflection commented 3 years ago

All right, I think I've fixed it.

nhoizey commented 3 years ago

@WebReflection I'll test in my code today, thanks a lot! 👍

WebReflection commented 3 years ago

I broke the build 🥳

... but now it should be fine.

nhoizey commented 3 years ago

I can confirm that the issue is fixed on my side, thanks A LOT for taking the time to fix it! 🙏