Comparing version 0.1.0 to 0.1.1
@@ -32,2 +32,8 @@ import Stamp from '../src/stamp.js' | ||
<div> | ||
<div class="custom-container"> | ||
<template id="tpl-custom-element"> | ||
<custom-element><div></div></custom-element> | ||
</template> | ||
</div> | ||
` | ||
@@ -218,2 +224,11 @@ | ||
// // Commented because Jest doesn't support custom elements yet. | ||
// test('Don\'t call callbacks on an unititiated custom-element.', () => { | ||
// let works = false | ||
// const changeWorks = () => works = true | ||
// Stamp('#tpl-custom-element') | ||
// .stamp(changeWorks) | ||
// expect(works).toBe(false) | ||
// }) | ||
test('Calls execute callbacks', () => { | ||
@@ -220,0 +235,0 @@ let works = false |
@@ -62,3 +62,10 @@ const stampData = {} | ||
if (callback) { | ||
callback(target.lastElementChild) | ||
const appendedElement = target.lastElementChild | ||
const tag = appendedElement.tagName.toLowerCase() | ||
if (tag.includes('-')) { | ||
customElements.whenDefined(tag) | ||
.then(() => callback(appendedElement)) | ||
} else { | ||
callback(appendedElement) | ||
} | ||
} | ||
@@ -65,0 +72,0 @@ } |
@@ -70,3 +70,10 @@ "use strict"; | ||
if (callback) { | ||
callback(target.lastElementChild); | ||
var appendedElement = target.lastElementChild; | ||
var tag = appendedElement.tagName.toLowerCase(); | ||
if (tag.includes('-')) { | ||
customElements.whenDefined(tag).then(() => callback(appendedElement)); | ||
} else { | ||
callback(appendedElement); | ||
} | ||
} | ||
@@ -73,0 +80,0 @@ } |
{ | ||
"name": "@dvo/stamp", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Tool for lightweight componentization.", | ||
"main": "lib/stamp.js", | ||
"scripts": { | ||
"test": "jest --watch --coverage", | ||
"test": "jest --watch --coverage", | ||
"runtest": "jest --coverage", | ||
@@ -29,8 +29,8 @@ "build": "babel ./src -d ./lib && mv ./lib/stamp.js ./lib/stamp.min.js && cp ./src/stamp.js ./lib/stamp.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.8.7", | ||
"@babel/preset-env": "^7.8.7", | ||
"babel-jest": "^25.1.0", | ||
"jest": "^25.1.0", | ||
"standard": "^14.3.1" | ||
"@babel/cli": "^7.10.5", | ||
"@babel/core": "^7.11.4", | ||
"@babel/preset-env": "^7.11.0", | ||
"babel-jest": "^25.5.1", | ||
"jest": "^25.5.4", | ||
"standard": "^14.3.4" | ||
}, | ||
@@ -37,0 +37,0 @@ "nyc": { |
@@ -155,4 +155,4 @@ # STAMP | ||
- `stamp()` <small>:function</small> Creates the component from the template, mutates it and appends to the target (by default, the template's container). If an argument function is passed, it will be run against the element *after* it is appended. | ||
- `stamp()` <small>:function</small> Creates the component from the template, mutates it and appends to the target (by default, the template's container). If an argument function is passed, it will be run against the element *after* it is appended. In the case of a web-component, the callback will run after the component is defined, so it's reliable to call on their methods. | ||
- `target()` <small>:string</small> Pass a selector to define a new target for the stamp. By default, the target is the template's parent element. |
@@ -62,3 +62,10 @@ const stampData = {} | ||
if (callback) { | ||
callback(target.lastElementChild) | ||
const appendedElement = target.lastElementChild | ||
const tag = appendedElement.tagName.toLowerCase() | ||
if (tag.includes('-')) { | ||
customElements.whenDefined(tag) | ||
.then(() => callback(appendedElement)) | ||
} else { | ||
callback(appendedElement) | ||
} | ||
} | ||
@@ -65,0 +72,0 @@ } |
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
31847
651