Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions assets/js/Components/Forms/AltText.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,18 @@ export default function AltText ({
let element = Html.toElement(html)

if (isDecorative) {
element = Html.setAttribute(element, "role", "presentation")

// <canvas> elements may have special roles, like "img", and we don't want to overwrite or remove those.
// <input> elements with type="image" also need to keep their role.
if(issue.scanRuleId !== 'canvas_content_described' && issue.scanRuleId !== 'imagebutton_alt_exists') {
element = Html.setAttribute(element, "role", "presentation")
}
element = Html.setAttribute(element, 'alt', '')
element = Html.setAttribute(element, 'title', '')
} else {
element = Html.removeAttribute(element, "role")
if(issue.scanRuleId !== 'canvas_content_described' && issue.scanRuleId !== 'imagebutton_alt_exists') {
element = Html.removeAttribute(element, "role")
}
element = Html.setAttribute(element, "alt", textInputValue)
element = Html.setAttribute(element, "title", textInputValue)
}
Expand Down
8 changes: 2 additions & 6 deletions assets/js/Components/Forms/SensoryMisuseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function SensoryMisuseForm({
const includedAttributes = ['alt', 'title', 'aria-label']

const editorRef = useRef(null)

const [sensoryErrors, setSensoryErrors] = useState([])

useEffect(() => {
Expand Down Expand Up @@ -107,12 +108,7 @@ export default function SensoryMisuseForm({
}

const traverseNode = (node) => {

// Editor HTML is empty so node ends up empty
if(node === null)
return

if (node.nodeType === Node.TEXT_NODE) {
if (node?.nodeType === Node.TEXT_NODE) {
// Check if the text node contains any sensory words
checkText(node.textContent);
}
Expand Down
15 changes: 14 additions & 1 deletion assets/js/Components/Forms/TableHeadersForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,24 @@ export default function TableHeadersForm({
}

const removeHeaders = (table) => {

// The table_structure_misuse rule means that when a table is marked as decorative,
// it should not contain any data-related elements, like <th> or <caption>. All 'summary',
// 'scope', and 'headers' attributes should also be removed.
if(decorationOnly) {
table.removeAttribute('summary')
let caption = table.querySelector('caption')
if(caption) {
caption.remove()
}
}

for (let row of table.rows) {
for (let cell of row.cells) {
cell.removeAttribute('scope')
cell.removeAttribute('headers')
if (cell.tagName === 'TH') {
let newCell = Html.renameElement(cell, 'td')
newCell.removeAttribute('scope')
row.replaceChild(newCell, cell)
}
}
Expand Down
1 change: 0 additions & 1 deletion assets/js/Components/Widgets/Combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

.combo-input {
background-color: var(--white);
display: block;
font-size: .85em;
padding: .4em .15em .4em .5em;
border: 1px solid var(--border-color);
Expand Down
1 change: 0 additions & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'regenerator-runtime/runtime'
import '@testing-library/jest-dom'

import { server } from './assets/js/__tests__/mocks/server.js'
import 'whatwg-fetch';

// Establish API mocking before all tests.
beforeAll(() => server.listen())
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
"@testing-library/user-event": "^14.6.1",
"copy-webpack-plugin": "13.0.0",
"jest": "^30.0.4",
"jest-environment-jsdom": "^30.0.4",
"msw": "^2.10.4",
"regenerator-runtime": "^0.14.1",
"webpack-cli": "^5.1.4",
"webpack-notifier": "^1.15.0",
"whatwg-fetch": "^3.6.20"
"webpack-notifier": "^1.15.0"
},
"license": "GPL-3.0-only",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/IssuesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function saveIssue(

$contentUpdated = true;
// Check if new HTML is different from original HTML
if ($newHtml !== '' && ($sourceHtml === $newHtml || $issue->getPreviewHtml() === $newHtml || $issue->getNewHtml() === $newHtml)) {
if ($sourceHtml === $newHtml || $issue->getPreviewHtml() === $newHtml || $issue->getNewHtml() === $newHtml) {
$contentUpdated = false;
}

Expand Down