Skip to content

Commit 322d916

Browse files
author
Steven Orvell
committed
Merge branch 'master' into update-external-samples
2 parents 29cf695 + b4c5f51 commit 322d916

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,32 @@ and renders declaratively using `lit-html`.
2323
be performed when a property is set, for example validation. Call `requestUpdate(name, oldValue)`
2424
in the setter to trigger an update and use any configured property options.
2525

26-
Properties can be given an options argument which is an object that describes how to
26+
Properties can be given an `options` argument which is an object that describes how to
2727
process the property. This can be done either in the `@property({...})` decorator or in the
2828
object returned from the `properties` getter, e.g. `static get properties { return { foo: {...} }`.
2929

3030
Property options include:
3131

3232
* `attribute`: Indicates how and whether the property becomes an observed attribute.
33-
If the value is `false`, the property is not added to `observedAttributes`.
34-
If true or absent, the lowercased property name is observed (e.g. `fooBar` becomes `foobar`).
33+
If the value is `false`, the property is not added to the static `observedAttributes` getter.
34+
If `true` or absent, the lowercased property name is observed (e.g. `fooBar` becomes `foobar`).
3535
If a string, the string value is observed (e.g `attribute: 'foo-bar'`).
3636
* `type`: Indicates how to serialize and deserialize the attribute to/from a property.
37-
If this value is a function, it is used to deserialize the attribute value
38-
a the property value. If it's an object, it can have keys for `fromAttribute` and
39-
`toAttribute` where `fromAttribute` is the deserialize function and `toAttribute`
40-
is a serialize function used to set the property to an attribute. If no `toAttribute`
41-
function is provided and `reflect` is set to `true`, the property value is set
42-
directly to the attribute.
43-
* `reflect`: Indicates if the property should reflect to an attribute.
44-
If `true`, when the property is set, the attribute is set using the
45-
attribute name determined according to the rules for the `attribute`
46-
property option and the value of the property serialized using the rules from
47-
the `type` property option.
48-
* `hasChanged`: A function that indicates if a property should be considered
49-
changed when it is set. The function should take the `newValue` and `oldValue`
50-
and return `true` if an update should be requested.
37+
The value can be a function used for both serialization and deserialization, or it can
38+
be an object with individual functions via the optional keys, `fromAttribute` and `toAttribute`.
39+
`type` defaults to the `String` constructor, and so does the `toAttribute` and `fromAttribute`
40+
keys.
41+
* `reflect`: Indicates whether the property should reflect to its associated
42+
attribute (as determined by the attribute option).
43+
If `true`, when the property is set, the attribute which name is determined
44+
according to the rules for the `attribute` property option, will be set to the
45+
value of the property serialized using the rules from the `type` property option.
46+
Note, `type: Boolean` has special handling by default which means that truthy
47+
values result in the presense of the attribute, where as falsy values result
48+
in the absense of the attribute.
49+
* `hasChanged`: A function that indicates whether a property should be considered
50+
changed when it is set and thus result in an update. The function should take the
51+
`newValue` and `oldValue` and return `true` if an update should be requested.
5152

5253
* **React to changes:** LitElement reacts to changes in properties and attributes by
5354
asynchronously rendering, ensuring changes are batched. This reduces overhead
@@ -197,7 +198,7 @@ into the element. This is the only method that must be implemented by subclasses
197198

198199
* A property is set (e.g. `element.foo = 5`).
199200
* If the property's `hasChanged(value, oldValue)` returns `false`, the element does not
200-
update. If it returns `true`, `requestUdpate()` is called to schedule an update.
201+
update. If it returns `true`, `requestUpdate()` is called to schedule an update.
201202
* `requestUpdate()`: Updates the element after awaiting a [microtask](https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/) (at the end
202203
of the event loop, before the next paint).
203204
* `shouldUpdate(changedProperties)`: The update proceeds if this returns `true`, which

0 commit comments

Comments
 (0)