Skip to content

Exceptions thrown when setting Element's innerHTML or innerText with non-string value #308

@chirsz-ever

Description

@chirsz-ever

Reproduciable example:

import { parseHTML } from 'linkedom';

const window = parseHTML('<!DOCTYPE html><html><head></head><body></body></html>');

// These are OK:
// window.document.body.innerHTML = '1';
// window.document.body.innerText = '1';

// These are not:
window.document.body.innerHTML = 1;
window.document.body.innerText = 1;

The behavior tested on the browser seems to be consistent with

set innerHTML(value) {
  internalSetInnerHTMLWithString(this, value === null ? '' : String(value));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions