Skip to content

Avoid direct modification of HTML #2174

Closed
@lindapaiste

Description

@lindapaiste

Wherever possible, the content of the page should be controlled through React using props and state. Modifying the content using pure JS should be avoided.

The example that I found which is easy to fix is in the Editor component:

this._cm.on('keyup', () => {
const temp = this.props.t('Editor.KeyUpLineNumber', {
lineNumber: parseInt(this._cm.getCursor().line + 1, 10)
});
document.getElementById('current-line').innerHTML = temp;
});

The line number should be stored as a state and then passed down as a prop to the EditorAccessibility component, which contains the 'current-line' element.

It also seems like there is some wonky stuff going on throughout the uploader, but I need to dig in there to see what the code is doing.

let inputHidden = '<input type="hidden" name="attachments[]" value="';

inputHidden += `${window.btoa(jsonStr)}" />`;
document.getElementById('uploader').innerHTML += inputHidden;

file.previewElement.classList.remove('dz-error');
file.previewElement.classList.add('dz-success');
file.previewElement.classList.add('dz-processing');
file.previewElement.querySelector('.dz-upload').style.width = '100%';

file.previewTemplate.className += ' uploading'; // eslint-disable-line

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Code QualityFor refactoring, cleanup, or improvements to maintainabilityArea:OptimizationCategory for site performance optimization and management

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions