gitlab-ce/spec/frontend/__helpers__/html_string_serializer.js

13 lines
430 B
JavaScript

export function test(received) {
return received && typeof received === 'string' && received.startsWith('<');
}
// eslint-disable-next-line max-params
export function serialize(received, config, indentation, depth, refs, printer) {
const parser = new DOMParser();
const doc = parser.parseFromString(received, 'text/html');
const el = doc.body.firstElementChild;
return printer(el, config, indentation, depth, refs);
}