Skip to content

Accordion: doesn't work in template with whitespaces #598

Open
@wkeese

Description

@wkeese

When you have an accordion inside a template, there's an exception instantiating the widget. For example, in a template:

        <d-accordion>
            <d-panel label="Title one">
                ...
            </d-panel>
            <d-panel label="Title two">
                ...

The problem happens because when the template is compiled, it ends up with statements like:

accordion.appendChild(document.createTextNode("..."))

(or something like that), and Accordion (and perhaps other widgets) aren't set up to handle that.

onAddChild: dcl.superCall(function (sup) {
    return function (node) {
        var res = sup.call(this, node);
        this._panelList.push(this._setupUpgradedChild(node));
        this.notifyCurrentValue("_panelList");
        return res;
    };
}),

The text should be ignored, not registered as a panel.

The workaround is to remove spaces between the nodes, like this:

        <d-accordion class="list"
            ><d-panel label="Title one">
                ...
            </d-panel
            ><d-panel label="Title two">
                ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions