Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not get script tag attrs. #143

Closed
Innei opened this issue Jun 18, 2022 · 2 comments
Closed

Can not get script tag attrs. #143

Innei opened this issue Jun 18, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@Innei
Copy link
Contributor

Innei commented Jun 18, 2022

Hi, guys. I want to get <script /> tag attrs such as src, but it always get undefined.

For example code below this:

var http = require("http");


const {DOMParser, parseHTML}  = require('linkedom');

// Standard way: text/html, text/xml, image/svg+xml, etc...
// const document = (new DOMParser).parseFromString(html, 'text/html');

// Simplified way for HTML
const {
  // note, these are *not* globals
  window, document, customElements,
  HTMLElement,
  Event, CustomEvent
  // other exports ..
} = parseHTML(`
  <!doctype html>
  <html lang="en">
    <head>
    <script type="module" crossorigin="" src="js/index-d2f678de.js"></script> // <------ script tag
      <title>Hello SSR</title>
    </head>
    <body>
      <form>
        <input name="user">
        <button>
          Submit
        </button>
      </form>
    </body>
  </html>
`);

  const $scripts = document.querySelectorAll(
      'script',)

console.log($scripts[0].src,$scripts[0].type); // undefined, undefined
@WebReflection
Copy link
Owner

PR welcome for this file which indeed has nothing special ... feel free to see how to add extra special accessors to an element

@WebReflection WebReflection added the enhancement New feature or request label Jun 18, 2022
@Innei
Copy link
Contributor Author

Innei commented Jun 19, 2022

#144 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants