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

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

Open
wkeese opened this issue Feb 24, 2016 · 1 comment
Open

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

wkeese opened this issue Feb 24, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@wkeese
Copy link
Member

wkeese commented Feb 24, 2016

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">
                ...
@wkeese wkeese added the bug label Feb 24, 2016
@wkeese wkeese self-assigned this Feb 24, 2016
@wkeese wkeese added this to the 0.9.0 milestone May 30, 2016
@wkeese
Copy link
Member Author

wkeese commented Aug 2, 2017

Probably delite/Container should be modified to only call onAddChild() for Elements, not for text nodes. Note that the spec for that method is confused in that it mentions both Element and Node as though they are identical.

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

No branches or pull requests

1 participant