Skip to content

Commit

Permalink
fix: vitest unexpected error
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0zy07 committed Nov 27, 2023
1 parent 1df5886 commit 43eee8a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/components/checkbox/src/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Checkbox = defineComponent({
const composedRefs = useComposedRefs(forwardedRef, buttonRef)
const hasConsumerStoppedPropagationRef = ref(false)
// We set this to true by default so that events bubble to forms without JS (SSR)
const isFormControl = computed(() => buttonRef.value ? Boolean(buttonRef.value?.closest('form')) : true)
const isFormControl = computed(() => buttonRef.value instanceof HTMLElement ? Boolean(buttonRef.value.closest('form')) : false)

const modelValue = useModel(props, 'modelValue')
const proxyChecked = computed({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,97 @@ exports[`okuCheckbox > should render OkuCheckbox correctly 1`] = `
`;
exports[`okuCheckbox > should render OkuCheckbox correctly 2`] = `"<primitivebutton-stub aschild=\\"false\\" type=\\"button\\" role=\\"checkbox\\" aria-checked=\\"false\\" aria-required=\\"false\\" data-state=\\"unchecked\\" disabled=\\"false\\" value=\\"on\\"></primitivebutton-stub>"`;
exports[`okuCheckbox > should render OkuCheckboxIndicator correctly 1`] = `"\`OkuCheckboxIndicator\` must be used within \`OkuCheckbox\`"`;
exports[`okuCheckbox Stories > animated > should render correctly 1`] = `
"<p>
<oku-checkbox-stub checked=\\"indeterminate\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
</p>
<button type=\\"button\\"> Toggle indeterminate </button>"
`;
exports[`okuCheckbox Stories > chromatic > should render correctly 1`] = `
"<h1>Uncontrolled</h1>
<h2>Unchecked</h2>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Checked</h2>
<oku-checkbox-stub defaultchecked=\\"true\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>Controlled</h1>
<h2>Unchecked</h2>
<oku-checkbox-stub checked=\\"false\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Checked</h2>
<oku-checkbox-stub checked=\\"true\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>Indeterminate</h1>
<oku-checkbox-stub checked=\\"indeterminate\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>Disabled</h1>
<oku-checkbox-stub defaultchecked=\\"true\\" required=\\"false\\" disabled=\\"true\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>Force mounted indicator</h1>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>State attributes</h1>
<h2>Unchecked</h2>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox-attr-styles\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Checked</h2>
<oku-checkbox-stub defaultchecked=\\"true\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox-attr-styles\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Indeterminate</h2>
<oku-checkbox-stub checked=\\"indeterminate\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox-attr-styles\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Disabled</h2>
<oku-checkbox-stub defaultchecked=\\"true\\" required=\\"false\\" disabled=\\"true\\" aschild=\\"false\\" class=\\"checkbox-attr-styles\\" value=\\"on\\"></oku-checkbox-stub>
<h2>Force mounted indicator</h2>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox-attr-styles\\" value=\\"on\\"></oku-checkbox-stub>"
`;
exports[`okuCheckbox Stories > controlled > should render correctly 1`] = `
"<p>This checkbox is placed adjacent to its label. The state is controlled.</p>
<label-stub for=\\"randBox\\"></label-stub>
<oku-checkbox-stub checked=\\"true\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" id=\\"randBox\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>"
`;
exports[`okuCheckbox Stories > indeterminate > should render correctly 1`] = `
"<p>
<oku-checkbox-stub checked=\\"indeterminate\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
</p>
<button type=\\"button\\"> Toggle indeterminate </button>"
`;
exports[`okuCheckbox Stories > styled > should render correctly 1`] = `
"<p>This checkbox is nested inside a label. The state is uncontrolled.</p>
<h1>Custom label</h1>
<label-stub></label-stub>
<br>
<br>
<h1>Native label</h1>
<label> Label <oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub></label>
<h1>Native label + native checkbox</h1>
<label> Label <input type=\\"checkbox\\"></label>
<h1>Custom label + htmlFor</h1>
<label-stub for=\\"one\\"></label-stub>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" id=\\"one\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<br>
<br>
<h1>Native label + htmlFor</h1>
<label for=\\"two\\">Label</label>
<oku-checkbox-stub required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" id=\\"two\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
<h1>Native label + native checkbox</h1>
<label for=\\"three\\">Label</label>
<input id=\\"three\\" type=\\"checkbox\\">"
`;
exports[`okuCheckbox Stories > withinForm > should render correctly 1`] = `
"<form>
<fieldset>
<legend>optional checked: false</legend><label>
<oku-checkbox-stub name=\\"optional\\" checked=\\"indeterminate\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub> with label
</label><br><br><button type=\\"button\\"> Toggle indeterminate </button>
</fieldset><br><br>
<fieldset>
<legend>required checked: false</legend>
<oku-checkbox-stub name=\\"required\\" required=\\"true\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
</fieldset><br><br>
<fieldset>
<legend>stop propagation checked: false</legend>
<oku-checkbox-stub name=\\"stopprop\\" required=\\"false\\" disabled=\\"false\\" aschild=\\"false\\" class=\\"checkbox\\" value=\\"on\\"></oku-checkbox-stub>
</fieldset><br><br><button type=\\"reset\\"> Reset </button><button>Submit</button>
</form>"
`;

0 comments on commit 43eee8a

Please sign in to comment.