Comments (7)
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.
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.
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.
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.
@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.
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.
@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)
- Anyone willing to help this project forward? HOT 8
- List optional dependencies in `peerDependencies` + `peerDependenciesMeta` HOT 1
- [META] Update changelog? HOT 1
- Creating script element resulting unexpected opening tag. HOT 1
- Support Node constructors HOT 1
- missing `customElements.getName()`
- Illegal constructor when extending DocumentFragment HOT 2
- replaceWith(...nodes) stuck if `nodes` contain the node that's being replaced
- CSSStyleSheet.insertRule returning undefined if index argument not provided HOT 3
- the hidden attribute parsing is not valid in xml HOT 3
- Error when using with axios: "TypeError: Cannot read properties of undefined (reading 'charAt')" HOT 1
- [BUG] `innerHTML` on elements parsed from XMLDocument doesn't escape characters as XML entities inside attribute values HOT 1
- `querySelectorAll` breaks when the DOM contains an element with a 'template' attribute HOT 1
- "perf_hooks" and "canvas" not found issue with using linkedom HOT 2
- " converted to " on xml HOT 4
- Value of a foreign input element is an attribue HOT 2
- `HTMLTimeElement` losts `dateTime` property HOT 1
- Proper types exports for `./worker` submodule HOT 1
- HTMLAnchorElement loses `rel` attribute after casting to string HOT 4
- In 'HTMLElement.classList.toggle' the 'force' attribute works uncorrectly.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linkedom.