You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
${this.property}, where property is either defined or not, does NOT give an error.
${variable}DOES give an error.
the presence of a backtick `DOES give an error, too.
Example
import{LitElement,html}from'lit';import{customElement,property}from'lit/decorators.js';
@customElement('my-element')exportclassmyElementextendsLitElement{
@property()fruit='apple';
@property()price=15;render(){returnhtml`<p>This is an ${this.fruit}!</p><p>It costs ${this.price} cents.</p><hr><!-- <div>The expression ${this.fruit} within a HTML comment does NOT give an error.</div> --><!-- <div>The expression ${this.variable} within a HTML comment does NOT give an error.</div> --><!-- <div>The expression ${variable} within a HTML comment DOES give an error!</div> --> <!-- <div>The backtick (`)withinaHTMLcommentDOESgiveanerror,too!</div> --><hr><!--/* <div>The expression ${this.fruit} within HTML and JS comment does NOT give an error.</div> */--><!--/* <div>The expression ${this.variable} within HTML and JS comments does NOT give an error.</div> */--><!--/* <div>The expression ${variable} within HTML and JS comments DOES give an error!</div> */--><!--/* <div>The backtick (`) within HTML and JS comments DOES give an error, too! */</div> -->
`;}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Keep in mind that:
${this.property}
, where property is either defined or not, does NOT give an error.${variable}
DOES give an error.`
DOES give an error, too.Example
Beta Was this translation helpful? Give feedback.
All reactions