-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
The DOM template is also processed to enable data binding and declarative event handlers. | ||
|
||
## Specify a DOM template | ||
|
||
Polymer provides three basic ways to specify a DOM template: | ||
To specify a template, defining a `template` property on the constructor. When extending an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defining -> define
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies in advance for any/most of these being things that I introduced when I updated this chapter... XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
||
### Specify a template using dom-module | ||
To specif the element's template, define a `template` property on the element's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specif -> specify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
oh crud I submitted the review - haven't finished it yet. pls disregard my review until further notice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd of 2 reviews because I accidentally submitted the first one
|
||
To specify an element's DOM template using a `<dom-module>`: | ||
The template getter must return an instance of `HTMLTemplateElement`. Use the `html` helper function | ||
to generate an `HTMLTemplateElement` instance from a JavaScript template literal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Use the html
helper function to generate..."
Do we need to say where to import it from?
"Import the html
helper function from polymer-element.js
and use it to generate..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the sample, but I added a parenthetical here so as not to make the sentence any more complicated than it was... WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine to me
customElements.define('child-class', ChildClass); | ||
``` | ||
|
||
[See a working example in Plunker](http://plnkr.co/edit/vS99al?p=preview). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://plnkr.co/edit/vS99al?p=preview Seems to be a 2.0 sample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced w/ correct sample. (I hope)
```js | ||
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js'; | ||
|
||
export class BaseClass extends Polymer.Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export class BaseClass extends Polymer.Element {
->
export class BaseClass extends PolymerElement {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
return `<style>:host { color: blue; }</style> | ||
<h2>String template</h2> | ||
<div>I've got a string template!</div>` | ||
export class BaseClass extends Polymer.Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export class BaseClass extends Polymer.Element {
->
export class BaseClass extends PolymerElement {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* The `html` function checks each expression value. If the expression is an | ||
`HTMLTemplateElement`, the `innerHTML` of the template is interpolated. | ||
* To protect against XSS vulnerabilities, `html` only interpolates `HTMLTemplateElement` | ||
values or template literals tagged with `htmlLiteral`. For information on usign `htmlLiteral` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usign
-> using
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
static get template() { | ||
return null; | ||
} | ||
``` | ||
|
||
### URLs in templates {#urls-in-templates} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLs in templates
I think some text needs updating in this section - it references HTML Imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is still sort of up in the air. I'll add a note here that the section needs to be updated when Polymer/polymer#5163 gets resolved.
@@ -226,12 +333,14 @@ Example: { .caption } | |||
<dom-module id="x-custom"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need the updated script, can html tags be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, fixed.
@@ -226,12 +333,14 @@ Example: { .caption } | |||
<dom-module id="x-custom"> | |||
|
|||
<template> | |||
Hello World from <span id="name"></span>! | |||
|
|||
</template> | |||
|
|||
<script> | |||
class MyElement extends Polymer.Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class MyElement extends Polymer.Element {
->
class MyElement extends PolymerElement {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -251,6 +360,9 @@ use the standard DOM `querySelector` method. | |||
|
|||
## Remove empty text nodes {#strip-whitespace} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping review of this section
@@ -338,14 +454,16 @@ This is a fairly rare use case. | |||
```html | |||
<dom-module id="custom-template"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, can remove html stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, fixed.
Updated, PTAL. |
No description provided.