element-internals-polyfill
Advanced tools
Comparing version 0.0.18 to 0.0.20
@@ -5,2 +5,11 @@ # Changelog | ||
### [0.0.20](https://github.com/calebdwilliams/element-internals-polyfill/compare/v0.0.19...v0.0.20) (2020-06-02) | ||
### [0.0.19](https://github.com/calebdwilliams/element-internals-polyfill/compare/v0.0.18...v0.0.19) (2020-06-02) | ||
### Bug Fixes | ||
* **polyfill:** small improvements and refactor of tests ([846f19d](https://github.com/calebdwilliams/element-internals-polyfill/commit/846f19d0dc03c0aa5d1da6d1f54464bfdd269e3d)) | ||
### [0.0.18](https://github.com/calebdwilliams/element-internals-polyfill/compare/v0.0.17...v0.0.18) (2020-05-27) | ||
@@ -7,0 +16,0 @@ |
@@ -150,4 +150,7 @@ (function () { | ||
label.addEventListener('click', ref.focus.bind(ref))); | ||
const firstLabelId = `${labels[0].htmlFor}_Label`; | ||
labels[0].id = firstLabelId; | ||
let firstLabelId = label[0].id; | ||
if (!labels[0].id) { | ||
firstLabelId = `${labels[0].htmlFor}_Label`; | ||
labels[0].id = firstLabelId; | ||
} | ||
ref.setAttribute('aria-labelledby', firstLabelId); | ||
@@ -333,2 +336,3 @@ } | ||
initForm(node, form, internals); | ||
initLabels(node, internals.labels); | ||
} | ||
@@ -365,2 +369,6 @@ | ||
class ElementInternals { | ||
static get isPolyfilled() { | ||
return true; | ||
} | ||
constructor(ref) { | ||
@@ -386,9 +394,10 @@ if (!ref || !ref.tagName || ref.tagName.indexOf('-') === -1) { | ||
const ref = refMap.get(this); | ||
const eventName = validity.valid ? 'valid' : 'invalid'; | ||
const validityEvent = new Event(eventName, { | ||
bubbles: false, | ||
cancelable: true, | ||
composed: false | ||
}); | ||
ref.dispatchEvent(validityEvent); | ||
if (!validity.valid) { | ||
const validityEvent = new Event('invalid', { | ||
bubbles: false, | ||
cancelable: true, | ||
composed: false | ||
}); | ||
ref.dispatchEvent(validityEvent); | ||
} | ||
return validity.valid; | ||
@@ -409,4 +418,7 @@ } | ||
const id = ref.getAttribute('id'); | ||
const hostRoot = getHostRoot(ref); | ||
return hostRoot ? hostRoot.querySelectorAll(`[for=${id}]`) : []; | ||
if (id) { | ||
const hostRoot = getHostRoot(ref); | ||
return hostRoot ? hostRoot.querySelectorAll(`[for=${id}]`) : []; | ||
} | ||
return []; | ||
} | ||
@@ -413,0 +425,0 @@ |
{ | ||
"name": "element-internals-polyfill", | ||
"version": "0.0.18", | ||
"version": "0.0.20", | ||
"description": "A polyfill for the element internals specification", | ||
@@ -11,3 +11,3 @@ "main": "dist/element-internals.js", | ||
"scripts": { | ||
"test": "karma start", | ||
"test": "karma start karma.conf.js --coverage", | ||
"test:watch": "npm run test -- --watch", | ||
@@ -46,7 +46,10 @@ "test:coverage": "npm run test -- --coverage", | ||
"@babel/preset-env": "^7.9.5", | ||
"@open-wc/testing": "^2.5.17", | ||
"@open-wc/testing-helpers": "^1.7.1", | ||
"@open-wc/testing-karma": "^3.4.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"babel-plugin-transform-async-to-promises": "^0.8.15", | ||
"karma": "^5.0.1", | ||
"deepmerge": "^4.2.2", | ||
"karma": "^5.0.9", | ||
"karma-chrome-launcher": "^3.1.0", | ||
@@ -58,6 +61,6 @@ "karma-coverage-istanbul-reporter": "^2.1.1", | ||
"karma-ie-launcher": "^1.0.0", | ||
"karma-jasmine": "^3.1.1", | ||
"karma-rollup-preprocessor": "^7.0.5", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-safarinative-launcher": "^1.1.0", | ||
"lit-html": "^1.2.1", | ||
"rollup": "^1.27.0", | ||
@@ -68,4 +71,6 @@ "rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-serve": "^1.0.1", | ||
"sinon": "^9.0.2", | ||
"standard-version": "^7.0.0" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
26224
457
27