-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: * Adding `??attr` binding syntax. * Changing `ifDefined` to delete attr on `null` as well as `undefined`. * Deprecating `ifDefined` / `nullish` in favor of `??attr` binding. * Deprecating `repeat` in favor of `map`. * Updating documentation. Closes #204.
- Loading branch information
1 parent
e975ecc
commit 73548db
Showing
15 changed files
with
1,607 additions
and
615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
import XElement from '../../x-element.js'; | ||
import { asyncAppend } from 'https://unpkg.com/[email protected]/directives/async-append.js'; | ||
import { asyncReplace } from 'https://unpkg.com/[email protected]/directives/async-replace.js'; | ||
import { cache } from 'https://unpkg.com/[email protected]/directives/cache.js'; | ||
import { classMap } from 'https://unpkg.com/[email protected]/directives/class-map.js'; | ||
import { directive } from 'https://unpkg.com/[email protected]/directive.js'; | ||
import { guard } from 'https://unpkg.com/[email protected]/directives/guard.js'; | ||
import { html, render as originalRender, svg } from 'https://unpkg.com/[email protected]/lit-html.js'; | ||
import { ifDefined } from 'https://unpkg.com/[email protected]/directives/if-defined.js'; | ||
import { live } from 'https://unpkg.com/[email protected]/directives/live.js'; | ||
import { repeat } from 'https://unpkg.com/[email protected]/directives/repeat.js'; | ||
import { styleMap } from 'https://unpkg.com/[email protected]/directives/style-map.js'; | ||
import { templateContent } from 'https://unpkg.com/[email protected]/directives/template-content.js'; | ||
import { unsafeHTML } from 'https://unpkg.com/[email protected]/directives/unsafe-html.js'; | ||
import { unsafeSVG } from 'https://unpkg.com/[email protected]/directives/unsafe-svg.js'; | ||
import { until } from 'https://unpkg.com/[email protected]/directives/until.js'; | ||
import { asyncAppend } from 'lit-html/directives/async-append.js'; | ||
import { asyncReplace } from 'lit-html/directives/async-replace.js'; | ||
import { cache } from 'lit-html/directives/cache.js'; | ||
import { choose } from 'lit-html/directives/choose.js'; | ||
import { classMap } from 'lit-html/directives/class-map.js'; | ||
import { directive } from 'lit-html/directive.js'; | ||
import { guard } from 'lit-html/directives/guard.js'; | ||
import { html, render as originalRender, svg } from 'lit-html/lit-html.js'; | ||
import { ifDefined } from 'lit-html/directives/if-defined.js'; | ||
import { join } from 'lit-html/directives/join.js'; | ||
import { keyed } from 'lit-html/directives/keyed.js'; | ||
import { live } from 'lit-html/directives/live.js'; | ||
import { map } from 'lit-html/directives/map.js'; | ||
import { range } from 'lit-html/directives/range.js'; | ||
import { ref } from 'lit-html/directives/ref.js'; | ||
import { repeat } from 'lit-html/directives/repeat.js'; | ||
import { styleMap } from 'lit-html/directives/style-map.js'; | ||
import { templateContent } from 'lit-html/directives/template-content.js'; | ||
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; | ||
import { unsafeSVG } from 'lit-html/directives/unsafe-svg.js'; | ||
import { until } from 'lit-html/directives/until.js'; | ||
import { when } from 'lit-html/directives/when.js'; | ||
|
||
|
||
export default class BaseElement extends XElement { | ||
// Use lit-html's template engine rather than the built-in x-element engine. | ||
static get templateEngine() { | ||
const render = (container, template) => originalRender(template, container); | ||
return { | ||
render, html, svg, asyncAppend, asyncReplace, cache, classMap, directive, | ||
guard, ifDefined, live, repeat, styleMap, templateContent, unsafeHTML, | ||
unsafeSVG, until, | ||
render, html, svg, asyncAppend, asyncReplace, cache, choose, classMap, | ||
directive, guard, ifDefined, join, keyed, live, map, range, ref, repeat, | ||
styleMap, templateContent, unsafeHTML, unsafeSVG, until, when, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"lit-html/": "https://esm.sh/[email protected]/" | ||
} | ||
} | ||
</script> | ||
<script type="module" src="./demo-lit-html.js"></script> | ||
</head> | ||
<body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ | |
height: calc(20px * 3); | ||
} | ||
|
||
#fixture { | ||
height: calc(20px * 9); | ||
color: gray; | ||
} | ||
|
||
p { | ||
width: 70ch; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,21 @@ | |
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"lit-html": "https://esm.sh/[email protected]", | ||
"uhtml": "https://esm.sh/[email protected]" | ||
} | ||
} | ||
</script> | ||
<link rel="stylesheet" href="./index.css"> | ||
</head> | ||
<body> | ||
<div> | ||
<div class="label">test fixture</div> | ||
<pre id="fixture" class="output"></pre> | ||
</div> | ||
<div> | ||
<div class="label">default</div> | ||
<pre id="default" class="output"></pre> | ||
|
Oops, something went wrong.