Skip to content

Commit

Permalink
Don't throw an error when focusing a newly created text-field
Browse files Browse the repository at this point in the history
  • Loading branch information
samiheikki authored and yuriy-fix committed Nov 8, 2018
1 parent 9819386 commit 9153ada
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vaadin-text-field-mixin.html
Expand Up @@ -236,7 +236,7 @@
}

get focusElement() {
return this.root.querySelector('[part=value]');
return this.root && this.root.querySelector('[part=value]');
}

_onInput(e) {
Expand Down
7 changes: 7 additions & 0 deletions test/text-field.html
Expand Up @@ -226,5 +226,12 @@
});
});
});

describe('methods', function() {
it('should not throw an error when using focus() to a newly created element', () => {
// No expect needed as an error is thrown when focusing undefined element
document.createElement('vaadin-text-field').focus();
});
});
</script>
</body>

0 comments on commit 9153ada

Please sign in to comment.