Configured cheerio to work with non-HTML standard elements to fix issues with custom component tags. (#79)

This commit is contained in:
Dominik Herbst 2017-11-07 15:13:01 +01:00 committed by Kim Biesbjerg
parent ee28fe2a64
commit 4892ea5146
2 changed files with 9 additions and 1 deletions

View File

@ -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 {

View File

@ -118,4 +118,10 @@ describe('DirectiveParser', () => {
expect(template).to.equal('<p translate="KEY">Hello World</p>');
});
it('should extract contents from within custom tags', () => {
const contents = `<custom-table><tbody><tr><td translate>Hello World</td></tr></tbody></custom-table>`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal(['Hello World']);
});
});