From 4892ea5146a195cdc3d512cb3ae8f6fbeb8304d6 Mon Sep 17 00:00:00 2001 From: Dominik Herbst Date: Tue, 7 Nov 2017 15:13:01 +0100 Subject: [PATCH] Configured cheerio to work with non-HTML standard elements to fix issues with custom component tags. (#79) --- src/parsers/directive.parser.ts | 4 +++- tests/parsers/directive.parser.spec.ts | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parsers/directive.parser.ts b/src/parsers/directive.parser.ts index c7114ea..d61da53 100644 --- a/src/parsers/directive.parser.ts +++ b/src/parsers/directive.parser.ts @@ -2,7 +2,9 @@ import { ParserInterface } from './parser.interface'; import { AbstractTemplateParser } from './abstract-template.parser'; import { TranslationCollection } from '../utils/translation.collection'; -import * as $ from 'cheerio'; +import * as cheerio from 'cheerio'; + +const $ = cheerio.load('', {xmlMode: true}); export class DirectiveParser extends AbstractTemplateParser implements ParserInterface { diff --git a/tests/parsers/directive.parser.spec.ts b/tests/parsers/directive.parser.spec.ts index 3ce777a..c1050f4 100644 --- a/tests/parsers/directive.parser.spec.ts +++ b/tests/parsers/directive.parser.spec.ts @@ -118,4 +118,10 @@ describe('DirectiveParser', () => { expect(template).to.equal('

Hello World

'); }); + it('should extract contents from within custom tags', () => { + const contents = `Hello World`; + const keys = parser.extract(contents, templateFilename).keys(); + expect(keys).to.deep.equal(['Hello World']); + }); + });