Skip to content

regression: syncSelectValue disregards data-display #99

@LuigiPulcini

Description

@LuigiPulcini

It appears that the new syncSelectValue – which was changed in this commit – fails to address the case where data-display is used in any of the options. Specifically, the issue occurs here:

let option = Array.from(select.options).find(option => option.textContent === item.data.text);

When data-display is used, t.data.text contains the value specified in data-display but option.textContent does not. So, for example, if you have:

<option value="my-bold-option" data-display="My <strong>bold</strong> option">My bold option</option>

then:

  • t.data.text is My <strong>bold</strong> option
  • but option.textContent is My bold option

As a result, the variable option stays undefined and an uncaught Javascript error is thrown here:

if(item.attributes.selected){
option.selected = true;
} else {
option.selected = false;
}

interrupting the execution of the importing script.

I tested a solution that takes the data-display case into account and will be happy to contribute with a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions