Skip to content

Commit

Permalink
Fix lit-ts template (#1494)
Browse files Browse the repository at this point in the history
* Fix lit-ts template

* Fixing generate Template

* Remove bad null check

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
  • Loading branch information
Orijhins and leaanthony committed Jun 27, 2022
1 parent 66f79c2 commit b2cec41
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,31 @@ export class MyElement extends LitElement {
}
`
}

@property()
resultText = "Please enter your name below 👇"
@property()
resultText = "Please enter your name below 👇"

greet()
{
let thisName = this.shadowRoot.getElementById('name').value
Greet(thisName).then(result => {
this.resultText = result
});
}
greet() {
let thisName = (this.shadowRoot.getElementById('name') as HTMLInputElement)?.value;
if (thisName) {
Greet(thisName).then(result => {
this.resultText = result
});
}
}

render()
{
return html`
<main>
<img id="logo" src=${logo} alt="Wails logo">
<div class="result" id="result">${this.resultText}</div>
<div class="input-box" id="input">
<input class="input" id="name" type="text" autocomplete="off"/>
<button @click=${this.greet} class="btn">Greet</button>
</div>
</main>
`
}
render() {
return html`
<main>
<img id="logo" src=${logo} alt="Wails logo">
<div class="result" id="result">${this.resultText}</div>
<div class="input-box" id="input">
<input class="input" id="name" type="text" autocomplete="off"/>
<button @click=${this.greet} class="btn">Greet</button>
</div>
</main>
`
}
}

declare global {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,31 @@ export class MyElement extends LitElement {
}
`
}

@property()
resultText = "Please enter your name below 👇"
@property()
resultText = "Please enter your name below 👇"

greet()
{
let thisName = this.shadowRoot.getElementById('name').value
Greet(thisName).then(result => {
this.resultText = result
});
}
greet() {
let thisName = (this.shadowRoot.getElementById('name') as HTMLInputElement)?.value;
if (thisName) {
Greet(thisName).then(result => {
this.resultText = result
});
}
}

render()
{
return html`
<main>
<img id="logo" src=${logo} alt="Wails logo">
<div class="result" id="result">${this.resultText}</div>
<div class="input-box" id="input">
<input class="input" id="name" type="text" autocomplete="off"/>
<button @click=${this.greet} class="btn">Greet</button>
</div>
</main>
`
}
render() {
return html`
<main>
<img id="logo" src=${logo} alt="Wails logo">
<div class="result" id="result">${this.resultText}</div>
<div class="input-box" id="input">
<input class="input" id="name" type="text" autocomplete="off"/>
<button @click=${this.greet} class="btn">Greet</button>
</div>
</main>
`
}
}

declare global {
Expand Down

0 comments on commit b2cec41

Please sign in to comment.