Skip to content

Svelte 5: TypeError while setting an attribute on a custom element in Adobe UXP #13726

@kapooostin

Description

@kapooostin

Describe the bug

Adobe UXP supports a subset of custom elements from Spectrum web components. They work fine in Svelte 4. With Svelte 5 it's impossible to use them as setting an attribute:

<sp-button variant="primary">Button</sp-button>

throws an error:

Uncaught TypeError: Cannot read properties of null (reading 'constructor')

But setting an event handler works as expected:

<sp-button onclick={()=>counter++}>Inc</sp-button>

I wrapped in the compiled script a troublesome call of

set_custom_element_data(sp_button, "variant", "primary")

into try/catch block and somehow it works if I attempt to set an attribute in a catch branch

try {
  set_custom_element_data(sp_button, "variant", "primary");
} catch(e) {
  set_custom_element_data(sp_button, "variant", "primary");
}

Reproduction

Not sure as you need Adobe Photoshop and dev environment to run and debug a plugin and the repo with the plugin to test. But I can write down the instructions on how to set up everything were anybody to bother.

Logs

/assets/index-B7eQNQ0h.js:2139 Uncaught TypeError: Cannot read properties of null (reading 'constructor')
    at get_setters (VM301 index-B7eQNQ0h.js:2139)
    at set_custom_element_data (VM301 index-B7eQNQ0h.js:2120)
    at App (VM301 index-B7eQNQ0h.js:2409)
    at VM301 index-B7eQNQ0h.js:2038
    at update_reaction (VM301 index-B7eQNQ0h.js:1033)
    at update_effect (VM301 index-B7eQNQ0h.js:1195)
    at create_effect (VM301 index-B7eQNQ0h.js:583)
    at branch (VM301 index-B7eQNQ0h.js:661)
    at VM301 index-B7eQNQ0h.js:2022
    at update_reaction (VM301 index-B7eQNQ0h.js:1033)

System Info

System:
    OS: macOS 14.6.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 4.71 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.1.0 - ~/.volta/tools/image/node/22.1.0/bin/node
    Yarn: 1.22.21 - ~/.volta/tools/image/yarn/1.22.21/bin/yarn
    npm: 10.8.3 - ~/.volta/tools/image/npm/10.8.3/bin/npm
    bun: 1.1.31 - ~/.volta/bin/bun
  Browsers:
    Chrome: 129.0.6668.101
    Safari: 17.6
  npmPackages:
    svelte: ^5.0.0-next.270 => 5.0.3
  
  Adobe Photoshop 25.15.0
    UXP 7.4.

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions