Allow time tag to retain 'datetime' attribute in RCE - #2532
Open
seanbeirnes wants to merge 1 commit into
Open
Conversation
This update improves accessibility for users. Updates CanvasSanitize to permit the `datetime` attribute only on <time> elements, adds corresponding spec coverage, and updates TinyMCE config to support it client side.
seanbeirnes
force-pushed
the
fix/tinymce/datetime
branch
from
August 17, 2025 01:56
8eb9c09 to
17be68c
Compare
Contributor
Author
|
I amended the commit to update the expected TinyMCE config test in defaultTinymceConfig.test.js so it would pass. One test is still failing due to QuotasTabContent.tsx. This file is unrelated to my changed files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The CanvasSanitize configuration previously allowed the
<time>tag but stripped itsdatetimeattribute. This caused semantic information about dates/times to be lost when user content was sanitized. The proposed change updates CanvasSanitize to preserve thedatetimeattribute on the<time>tag. Corresponding RSpec coverage was added to ensure the attribute is retained exclusively on<time>. The TinyMCE config for the Rich Content Editor (RCE) was also updated to reflect this added support on the client side.Reasons for Proposal
Preserving Semantics
The
datetimeattribute is an important part of the<time>element in HTML, allowing dates/times to be machine-readable by assistive technologies, user agents, and scripts. Stripping the attribute undermines the element’s intended semantic use.Source: MDN
Accessibility
This change improves conformance with WCAG 2.2 SC 1.3.1 Info and Relationships (Level A) by preserving the semantic relationship between the visible date text and its machine-readable representation. This helps screen readers and other tools interpret temporal information more accurately.
For example, the following HTML snippet semantically uses the
<time>tag anddatetimeattribute to remove ambiguity for visually impaired users. It is a duration of 12 minutes and 30 seconds, not 12 hours and 30 minutes or a time of day.The ISO 8601 datetime string above maps to the following:
P = "period"
T = "time component"
12M = "12 minutes"
30S = "30 seconds"
Proposed Change
datetimeattribute only on<time>elements.datetimeon<time>.Test Plan
<time datetime="...">retains its attribute while other elements (<div datetime>,<span datetime>) have it stripped.