api-viewer-element
Advanced tools
Comparing version 0.3.10 to 0.3.11
@@ -19,2 +19,12 @@ # Change Log | ||
## [0.3.11] - 2020-02-04 | ||
### Changed | ||
- Demo: wait for LitElement / Stencil update | ||
### Fixed | ||
- Demo: sync property knobs when true by default | ||
## [0.3.10] - 2020-02-04 | ||
@@ -21,0 +31,0 @@ |
@@ -249,3 +249,8 @@ import { __decorate } from "tslib"; | ||
this.props | ||
.filter(prop => component[prop.name] !== getDefault(prop)) | ||
.filter(prop => { | ||
const { name, type } = prop; | ||
const defaultValue = getDefault(prop); | ||
return (component[name] !== defaultValue || | ||
(normalizeType(type) === 'boolean' && defaultValue)); | ||
}) | ||
.forEach(prop => { | ||
@@ -252,0 +257,0 @@ this._syncKnob(component, prop); |
@@ -42,2 +42,28 @@ import { directive, NodePart } from 'lit-html'; | ||
}; | ||
const isDefinedPromise = (action) => typeof action === 'object' && Promise.resolve(action) === action; | ||
/** | ||
* Awaits for "update complete promises" of elements | ||
* - for [lit-element](https://github.com/polymer/lit-element) that is `el.updateComplete`; | ||
* - for [stencil](https://github.com/ionic-team/stencil/) that is `el.componentOnReady()`; | ||
* | ||
* If none of those Promise hooks are found, it will wait for `setTimeout`. | ||
*/ | ||
async function elementUpdated(element) { | ||
let hasSpecificAwait = false; | ||
const el = element; | ||
const litPromise = el.updateComplete; | ||
if (isDefinedPromise(litPromise)) { | ||
await litPromise; | ||
hasSpecificAwait = true; | ||
} | ||
const stencilPromise = el.componentOnReady ? el.componentOnReady() : false; | ||
if (isDefinedPromise(stencilPromise)) { | ||
await stencilPromise; | ||
hasSpecificAwait = true; | ||
} | ||
if (!hasSpecificAwait) { | ||
await new Promise(resolve => setTimeout(() => resolve())); | ||
} | ||
return el; | ||
} | ||
export const renderer = directive((tag, knobs, slots, cssProps) => (part) => { | ||
@@ -66,3 +92,3 @@ if (!(part instanceof NodePart)) { | ||
// wait for rendering | ||
setTimeout(() => { | ||
elementUpdated(instance).then(() => { | ||
instance.dispatchEvent(new CustomEvent('rendered', { | ||
@@ -69,0 +95,0 @@ detail: { |
{ | ||
"name": "api-viewer-element", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"description": "Web Components API viewer element", | ||
@@ -5,0 +5,0 @@ "author": "Serhii Kulykov <iamkulykov@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203737
88
2224