Skip to content

postMessage not injected by webview when loading svelte applcation with bind:clientHeight #2716

@9ParsonsB

Description

@9ParsonsB

Describe the bug

When loading a svelte application with bind:clientHeight or bind:clientWidth on one of the elements on the page, window.chrome.webview.postMessage() is undefined due to delayed firing of DOMContentLoaded event

To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo (or use bind:clientWidth on any component)
  2. yarn tauri dev && yarn dev
  3. Open Browser DevTools
  4. See error

Expected behavior

No Error

Platform and Versions:

Operating System - Windows, version 10.0.22458 X64
Webview2 - 94.0.992.31

Node.js environment
  Node.js - 16.10.0
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 7.22.0
  yarn - 1.22.11

Rust environment
  rustc - 1.57.0-nightly
  cargo - 1.57.0-nightly

App directory structure
/.git
/.vscode
/node_modules
/src
/src-tauri
/wwwroot

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../wwwroot
  devPath - http://localhost:5000
  framework - Svelte
  bundler - Rollup

Additional Information:

Discord support conversion

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'postMessage')
    at Object.invoke (<anonymous>:2:62)
    at Rpc.notify (<anonymous>:41:41)
    at <anonymous>:121:20
    at new Promise (<anonymous>)
    at invoke (<anonymous>:102:12)
    at <anonymous>:396:18
    at append (index.mjs:309)
    at add_resize_listener (index.mjs:712)
    at Object.m (App.svelte:5)
    at mount_component (index.mjs:1727)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions