Skip to content

Commit 7c69413

Browse files
committed
feat(cc-form-control-element): add form getter
Fixes #1206
1 parent 7c49b53 commit 7c69413

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/lib/form/cc-form-control-element.abstract.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ export class CcFormControlElement extends LitElement {
229229
}
230230
}
231231

232+
/**
233+
* @return {HTMLFormElement|null}
234+
*/
235+
get form() {
236+
return this._internals.form;
237+
}
238+
232239
/* endregion */
233240

234241
/* region mimic the native validation API */

test/form/cc-form-control-element.abstract.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,16 @@ describe('InputElement', () => {
610610

611611
expect(formControlElement.value).to.eql('reset value');
612612
});
613+
614+
it('should have the right form element', async () => {
615+
const customElement = getCustomElement();
616+
617+
/** @type {HTMLFormElement} */
618+
const formElement = await getElement(
619+
`<form><${customElement} name="input" value="current value"></${customElement}></form>`,
620+
);
621+
const formControlElement = formElement.querySelector(customElement);
622+
623+
expect(formControlElement.form).to.eql(formElement);
624+
});
613625
});

0 commit comments

Comments
 (0)