Skip to content

Commit

Permalink
Merge pull request #1194 from seanpdoyle/fix-ci-validationMessage
Browse files Browse the repository at this point in the history
Fix CI: `.validationMessage` assertion
  • Loading branch information
jorgemanrubia authored Oct 15, 2024
2 parents 5c05d83 + 832fc6e commit d3cb49c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/test/system/custom_element_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rangesAreEqual } from "trix/core/helpers"
import { makeElement, rangesAreEqual } from "trix/core/helpers"
import TrixEditorElement from "trix/elements/trix_editor_element"

import {
Expand Down Expand Up @@ -635,6 +635,7 @@ testGroup("form property references its <form>", { template: "editors_with_forms
testIf(TrixEditorElement.formAssociated, "validates with [required] attribute as invalid", () => {
const editor = document.getElementById("editor-with-ancestor-form")
const form = editor.form
const invalidInput = makeElement("input", { required: true })
let invalidEvent, submitEvent = null

editor.addEventListener("invalid", event => invalidEvent = event, { once: true })
Expand All @@ -646,7 +647,7 @@ testGroup("form property references its <form>", { template: "editors_with_forms
// assert.equal(document.activeElement, editor, "editor receives focus")
assert.equal(editor.required, true, ".required property retrurns true")
assert.equal(editor.validity.valid, false, "validity.valid is false")
assert.equal(editor.validationMessage, "Please fill out this field.", "sets .validationMessage")
assert.equal(editor.validationMessage, invalidInput.validationMessage, "sets .validationMessage")
assert.equal(invalidEvent.target, editor, "dispatches 'invalid' event on editor")
assert.equal(submitEvent, null, "does not dispatch a 'submit' event")
})
Expand Down
2 changes: 1 addition & 1 deletion src/trix/elements/trix_editor_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ElementInternalsDelegate {
const { required, value } = this.element
const valueMissing = required && !value
const customError = !!customValidationMessage
const input = Object.assign(document.createElement("input"), { required })
const input = makeElement("input", { required })
const validationMessage = customValidationMessage || input.validationMessage

this.#internals.setValidity({ valueMissing, customError }, validationMessage)
Expand Down

0 comments on commit d3cb49c

Please sign in to comment.