diff --git a/packages/critters/src/dom.js b/packages/critters/src/dom.js index 84f6b01..905503e 100644 --- a/packages/critters/src/dom.js +++ b/packages/critters/src/dom.js @@ -53,7 +53,7 @@ function buildCache(container) { * @param {String} html HTML to parse into a Document instance */ export function createDocument(html) { - const document = /** @type {HTMLDocument} */ (parseDocument(html)); + const document = /** @type {HTMLDocument} */ (parseDocument(html, {decodeEntities: false})); defineProperties(document, DocumentExtensions); diff --git a/packages/critters/test/critters.test.js b/packages/critters/test/critters.test.js index ee3af36..cfb51c6 100644 --- a/packages/critters/test/critters.test.js +++ b/packages/critters/test/critters.test.js @@ -95,4 +95,19 @@ describe('Critters', () => { expect(result).toMatch(''); expect(result).toMatch('$title'); }); + + test('Does not decode entities in HTML document', async () => { + const critters = new Critters({ + path: '/' + }); + critters.readFile = (filename) => assets[filename]; + const result = await critters.process(trim` + + + <h1>Hello World!</h1> + + + `); + expect(result).toMatch('<h1>Hello World!</h1>'); + }); });