Skip to content
This repository has been archived by the owner on Jun 9, 2019. It is now read-only.

43081j/lit-element-serializers

Repository files navigation

lit-element-serializers

A selection of common attribute serializers for use with LitElement.

These allow simple (de)serialization around common data structures such as objects, dates, strings and so on.

Install

Simple:

$ npm i -S lit-element-serializers

Usage

To use these:

import { NullableStringSerializer } from 'lit-element-serializers';

class MyElement extends LitElement {
  @property({ type: NullableStringSerializer })
  foo = 'test';
}

Serializers

NullableStringSerializer

The nullable string serializer allows easy serialization between string values and null or the given value, meaning falsy strings will be treated and set on your element as null.

ObjectSerializer

Simply a wrapper around JSON.parse and JSON.stringify, so any value passed to the property using this serializer will attempt to parse or output JSON.

This behaves similar to how type: Object did in Polymer.

About

Common attribute serializers for lit-element

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published