{"record":{"id":"8ef33ed716e67d7d","repo":"basecamp/trix","slug":"this-browser-does-not-support-checkvalidity-for","errorCode":null,"errorMessage":"This browser does not support checkValidity() for trix-editor elements.","messagePattern":"This browser does not support checkValidity\\(\\) for trix-editor elements\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/trix/elements/trix_editor_element.js","lineNumber":354,"sourceCode":"    console.warn(\"This browser does not support the validationMessage property for trix-editor elements.\")\n\n    return \"\"\n  }\n\n  get willValidate() {\n    console.warn(\"This browser does not support the willValidate property for trix-editor elements.\")\n\n    return false\n  }\n\n  formDisabledCallback(value) {\n  }\n\n  setFormValue(value) {\n  }\n\n  checkValidity() {\n    console.warn(\"This browser does not support checkValidity() for trix-editor elements.\")\n\n    return true\n  }\n\n  reportValidity() {\n    console.warn(\"This browser does not support reportValidity() for trix-editor elements.\")\n\n    return true\n  }\n\n  setCustomValidity(validationMessage) {\n    console.warn(\"This browser does not support setCustomValidity(validationMessage) for trix-editor elements.\")\n  }\n\n  #resetBubbled = (event) => {\n    if (event.defaultPrevented) return\n    if (event.target !== this.element.form) return\n    this.element.reset()","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/basecamp/trix/blob/470040131122bd44e269b4de0f2e9557f90ec994/src/trix/elements/trix_editor_element.js#L336-L372","documentation":"checkValidity() on trix-editor is a fallback that warns and returns true in browsers without form-associated custom element support, since the element cannot participate in native constraint validation. Callers may mistakenly conclude the editor is valid without any actual check. Non-fatal console warning.","triggerScenarios":"Calling 'trixEditor.checkValidity()' (directly or via form validation loops over form.elements) in an unsupported browser, executing the stub at trix_editor_element.js:353-357.","commonSituations":"Form-wide validation before submit, libraries iterating all controls with checkValidity, older Safari/Firefox environments.","solutions":["Validate the trix-editor's value yourself (e.g., editor.value non-empty) instead of relying on checkValidity().","Only call checkValidity when the browser supports form-associated custom elements; otherwise use custom validation.","Use a form submit handler that runs custom checks for trix-editor and native checks for other fields.","Accept/filter the warning since returning true safely avoids blocking submits."],"exampleFix":"// before\nif (!formEl.checkValidity()) return;\n// after\nconst valid = formEl.tagName === 'TRIX-EDITOR'\n  ? Boolean(formEl.value.trim())\n  : formEl.checkValidity();\nif (!valid) return;","handlingStrategy":"validation","validationCode":"const isTrix = el.tagName === 'TRIX-EDITOR';\nconst valid = isTrix ? Boolean(el.value.trim()) : el.checkValidity();","typeGuard":"function isValidControl(el) {\n  return el.tagName === 'TRIX-EDITOR'\n    ? Boolean(el.value.trim())\n    : typeof el.checkValidity === 'function' && el.checkValidity();\n}","tryCatchPattern":"try {\n  const ok = editor.checkValidity();\n} finally {\n  // checkValidity() on trix-editor always returns true in unsupported browsers:\n  // always also run manual value validation\n}\nconst ok = isValidControl(editor);","preventionTips":["Never trust checkValidity()===true for trix-editor in legacy browsers","Iterate form.elements with a per-type validation strategy","Add explicit required/non-empty checks for rich-text editors","Log which validation path runs so silent true-returns are visible"],"tags":["browser-compatibility","custom-elements","validation","console-warning"],"backgroundTag":"form-associated-custom-element-unsupported","analyzedSha":"470040131122bd44e269b4de0f2e9557f90ec994","analyzedAt":"2026-09-02T10:19:15.878Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}