@justeattakeaway/pie-webc-core
Advanced tools
Comparing version 0.0.0-snapshot-release-20240405122316 to 0.0.0-snapshot-release-20240409162316
# Changelog | ||
## 0.0.0-snapshot-release-20240405122316 | ||
## 0.0.0-snapshot-release-20240409162316 | ||
@@ -5,0 +5,0 @@ ### Minor Changes |
@@ -72,3 +72,3 @@ import { isServer as c } from "lit"; | ||
} | ||
class d { | ||
class u { | ||
constructor() { | ||
@@ -88,3 +88,3 @@ this._forms = /* @__PURE__ */ new WeakMap(); | ||
addForm(e) { | ||
if (this._forms.get(e)) | ||
if (this.getForm(e)) | ||
return; | ||
@@ -102,3 +102,3 @@ const r = { | ||
deleteForm(e) { | ||
const n = this._forms.get(e); | ||
const n = this.getForm(e); | ||
n != null && n.listener && e.removeEventListener("submit", n.listener), this._forms.delete(e); | ||
@@ -126,3 +126,3 @@ } | ||
var r; | ||
super.connectedCallback(), this.form && (window.pieFormManager || (window.pieFormManager = new d()), window.pieFormManager && (window.pieFormManager.addForm(this.form), this._managedForm = (r = window.pieFormManager.getForm(this.form)) == null ? void 0 : r.form)); | ||
super.connectedCallback(), this.form && (window.pieFormManager || (window.pieFormManager = new u()), window.pieFormManager.addForm(this.form), this._managedForm = (r = window.pieFormManager.getForm(this.form)) == null ? void 0 : r.form); | ||
} | ||
@@ -137,3 +137,3 @@ disconnectedCallback() { | ||
F as FormControlMixin, | ||
d as PieFormManager, | ||
u as PieFormManager, | ||
b as RtlMixin, | ||
@@ -140,0 +140,0 @@ p as defineCustomElement, |
{ | ||
"name": "@justeattakeaway/pie-webc-core", | ||
"version": "0.0.0-snapshot-release-20240405122316", | ||
"version": "0.0.0-snapshot-release-20240409162316", | ||
"description": "PIE design system base classes, mixins and utilities for web components", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,2 +0,2 @@ | ||
import { PIEInputElement } from '../interfaces'; | ||
import type { PIEInputElement } from '../interfaces'; | ||
@@ -37,3 +37,3 @@ /** | ||
public addForm (form: HTMLFormElement): void { | ||
const existingEntry = this._forms.get(form); | ||
const existingEntry = this.getForm(form); | ||
@@ -59,3 +59,3 @@ if (existingEntry) { | ||
public deleteForm (form: HTMLFormElement): void { | ||
const data = this._forms.get(form); | ||
const data = this.getForm(form); | ||
@@ -62,0 +62,0 @@ if (data?.listener) { |
@@ -60,3 +60,3 @@ import type { LitElement } from 'lit'; | ||
connectedCallback (): void { | ||
override connectedCallback (): void { | ||
super.connectedCallback(); | ||
@@ -70,11 +70,9 @@ | ||
if (window.pieFormManager) { | ||
window.pieFormManager.addForm(this.form); | ||
// Storing a reference to the form to be used in disconnectedCallback when this.form will be unavailable. | ||
this._managedForm = window.pieFormManager.getForm(this.form)?.form; | ||
} | ||
window.pieFormManager.addForm(this.form); | ||
// Storing a reference to the form to be used in disconnectedCallback when this.form will be unavailable. | ||
this._managedForm = window.pieFormManager.getForm(this.form)?.form; | ||
} | ||
} | ||
disconnectedCallback (): void { | ||
override disconnectedCallback (): void { | ||
super.disconnectedCallback(); | ||
@@ -81,0 +79,0 @@ |
@@ -1,8 +0,1 @@ | ||
import { | ||
describe, | ||
it, | ||
expect, | ||
vi, | ||
} from 'vitest'; | ||
import { PieFormManager } from '../../forms/pie-form-manager'; | ||
@@ -62,2 +55,3 @@ | ||
expect(result?.form).toStrictEqual(testForm); | ||
expect(result?.listener).toBeInstanceOf(Function); | ||
}); | ||
@@ -80,20 +74,2 @@ | ||
}); | ||
it('returns undefined when a form has been deleted', () => { | ||
// Arrange | ||
document.body.innerHTML = ` | ||
<form id="testForm"></form> | ||
`; | ||
const testForm = document.getElementById('testForm') as HTMLFormElement; | ||
const manager = new PieFormManager(); | ||
manager.addForm(testForm); | ||
manager.deleteForm(testForm); | ||
// Act | ||
const result = manager.getForm(testForm); | ||
// Assert | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
@@ -100,0 +76,0 @@ |
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
62080
1253