paper-input icon indicating copy to clipboard operation
paper-input copied to clipboard

inputElement does not return native HTML input element [Polymer 2]

Open MarcMouallem opened this issue 7 years ago • 3 comments

inputElement does not return the native HTML input element but instead returns <iron-input>.

This almost certainly has to do with Polymer 2 doing away with the is attribute and requiring the use of <iron-input> as a wrapper in this case. Since you guys know the code way better than I do you could probably track this down in a second; it would take me much longer, so when you get a chance :)

Workaround: this.$.myPaperInput.inputElement.querySelector('input')

MarcMouallem avatar May 03 '17 21:05 MarcMouallem

I think this change needs to be better documented, and also is wrong in the documentation

inputElement is a getter on paper-input but the docs (for paper-input-behavior) says it is a function

@MarcMouallem for info

In Polymer 1 I had this.$.myPaperInput.inputElement.setSelectRange(0,5); In Polymer 2 I have to do this.$.myPaperInput.inputElement.inputElement.setSelectRange(0,5);

akc42 avatar May 30 '17 12:05 akc42

yeah....so the hybrid element will return the iron-input for inputElement: this will be the native input in 1.0 but the wrapper in 2.0 (this is because you need to interact with the thing that manages the native input, and that's different in each context. I agree the docs can be phrased a little better than "Returns a reference to the input element."

notwaldorf avatar May 30 '17 22:05 notwaldorf

@notwaldorf The paper-input-behavior api docs refer to inputElement as a "Method", but its a getter, so should be referred to as a "Property"

akc42 avatar May 31 '17 07:05 akc42