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

[bug] web_dev_server removes HTML template element contents #6165

Closed
AlainSchneble opened this issue Jan 29, 2023 · 0 comments
Closed

[bug] web_dev_server removes HTML template element contents #6165

AlainSchneble opened this issue Jan 29, 2023 · 0 comments

Comments

@AlainSchneble
Copy link
Contributor

AlainSchneble commented Jan 29, 2023

Describe the bug

When serving html files through web_dev_server by using cargo tauri dev, any template element contents in the served HTML are removed.

While looking further into this issue, the culprit seem to be this:

f = document.to_string().as_bytes().to_vec();

FMPOV, this should be changed to:

f = tauri_utils::html::serialize_node(&document);

(I've actually tried this change out and it solves the issue)

A similar issue has already been fixed for the assets compilation process / asset csp modification, see #5247 (and also #4410) but the web_dev_server hasn't catched up with this change.

Reproduction

  1. cargo create-tauri-app

  2. Select plain vanilla HTML/CSS/JavaScript

  3. Add the following template element before the closing body tag in src/index.html:

<template>
    <tr>
        <td>[ID]</td>
        <td>[Name]</td>
    <tr>
</template>
  1. cargo tauri dev
  2. Inspect the DOM and observe that the template element is empty

Expected behavior

HTML template element contents should be served properly.

For the example above, I would expect to see the following children when inspecting the DOM:

<template>
    #document-fragment
        <tr>
            <td>[ID]</td>
            <td>[Name]</td>
        <tr>
</template>

Platform and versions

Environment
  › OS: Windows 10.0.19045 X64
  › Webview2: 109.0.1518.69
  › MSVC:
      - Visual Studio Community 2022
      - Visual Studio Community 2019
  › Node.js: 19.1.0
  › npm: 8.19.3
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.66.1
  › cargo: 1.66.1
  › Rust toolchain: stable-x86_64-pc-windows-msvc 

Packages                                       
WARNING: no lock files found, defaulting to npm
  › @tauri-apps/cli [NPM]: 1.2.3
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 1.2.4,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: default-src 'self'
  › distDir: ../src
  › devPath: ../src
package.json not found

App directory structure
  ├─ .vscode
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

No response

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

No branches or pull requests

1 participant