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

md-option doesn't accept non-text prop #2116

Open
chrislebaron opened this issue Sep 2, 2019 · 0 comments
Open

md-option doesn't accept non-text prop #2116

chrislebaron opened this issue Sep 2, 2019 · 0 comments

Comments

@chrislebaron
Copy link

chrislebaron commented Sep 2, 2019

md-option will not accept a slot that includes anything other than text elements. If you try to pass HTML or an icon etc, it will throw a nasty error in your face because of the way the getTextContent function is written.

Which browser?

All

What is expected?

Should be able to pass a slot with whatever HTML you want

What is actually happening?

An error is thrown in the getTextContent function because it hits an undefined value if you pass HTML into the slot.

Proposed fix

The getTextContent function could be redefined like this to avoid failure if HTML content is passed in:

getTextContent (children) {
        let that = this;
        return children.map(function (node) {
          return node.children
                  ? that.getTextContent(node.children)
                  : node.text
        }).join('')
      },

The setItem function could be redefined like this:

setItem () {
        this.$set(this.MdSelect.items, this.key, this.getTextContent(this.$slots.default))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant