Coder Social home page Coder Social logo

Attributes missing about linkedom HOT 7 CLOSED

webreflection avatar webreflection commented on June 29, 2024 1
Attributes missing

from linkedom.

Comments (7)

cramforce avatar cramforce commented on June 29, 2024 1

The new version doesn't fix it, but I have a minimal repro:

const { parseHTML } = require("linkedom");

console.log(
  `type="test" is retained`,
  parseHTML(`<!doctype html><script type="test"></script>`).document.toString()
);

console.log(
  `type="test" is dropped`,
  parseHTML(`<!doctype html><script type="test">X</script>`).document.toString()
);

Output:

type="test" is retained <!DOCTYPE html><html><script type="test"></script></html>
type="test" is dropped <!DOCTYPE html><html><script>X</script></html>

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

I've just tried:

const {document} = parseHTML('');
document.head.innerHTML = `<script csp-hash="any"></script>`;
console.log(document.querySelector("script[csp-hash]").toString());

And the outcome is:

<script csp-hash="any"></script>

While document.toString() produces:

<!DOCTYPE html><html><head><script csp-hash="any"></script></head></html>

Is it something inside the script that is not available? <script>, together with <style> or <textarea> and <title> have a special behavior for content, as these don't accept Element nodes inside.

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

P.S. the window, in linkedom, has to be retrieved via document.defaultView but it doesn't have a document attached ... that is something I can fix though.

edit this change is in.

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

I've made a few changes that maybe help you sorting out what's going on:
https://github.com/WebReflection/linkedom#simulating-json-bootstrap

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

@cramforce there are a lot of tiny fixes in the latest version, please have a look at both how to simulate JSDOM and with latest, to see if your problem is gone.

I don't have much to reproduce or test, so if I won't hear from you in a couple of days, I'll close this 👋

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

Thanks for the reproducible example!

FWIW, it's a specific <script> special case (change name to see it working), meaning it likely affects <style> and <title> too ... these are all special cases, and I'll try to fix this ASAP as these are also most important nodes that should work 😅

thank for your patience, I'll come back hopefully sooner than later.

from linkedom.

WebReflection avatar WebReflection commented on June 29, 2024

@cramforce this issue has been fixed, I hope you won't have any other, but if that's the case, please open a new issue and I'll follow up. Thanks for the example, it helped a lot (and it should've been in my coverage in the first place).

Now all cases are tested, and it's green 👍

from linkedom.

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.