PolymerElements / paper-input

A Material Design text field
https://www.webcomponents.org/element/PolymerElements/paper-input
130 stars 162 forks source link

paper input container throwing null ref exception #634

Closed jogibear9988 closed 6 years ago

jogibear9988 commented 6 years ago

I use this code in my index.html:

        <paper-input-container>
            <label slot="label"><t-t>Username</t-t></label>
            <iron-input slot="input">
                <input style="all: inherit; background: transparent; border: none;" type="text" id="username" label="Username" required autocomplete="on">
            </iron-input>
        </paper-input-container>

but paper input container is throwing a exception in line

  https://github.com/PolymerElements/paper-input/blob/43ad083cc29680f9a02fc3415220bd3cb1b8967d/paper-input-container.html#L525

because of this._inputElement is null.

I could not explain it! When I debug my code, the paper-input-container has no children. But after that, the code is displayed and works as expected! Has anyone any idea?

notwaldorf commented 6 years ago

Distribution is asynchronous, so if you're writing a test where you are checking for the presence of the input element, you need to wait a tick (wrap the test in a Polymer.Base.Async or a setTimeout)

Otherwise, I can't reproduce this just by dropping an element in the page, so it's probably some JS code you wrote: http://jsbin.com/hovahac/edit?html,output