From 2294c1967f6d23b7a518a8faa242653406f944b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 23 Aug 2019 15:15:40 +0200 Subject: [PATCH] [IMP] qweb: allow xml documents as template definition Before this commit, the addTemplates method only accepts a string. But whenever we perform a $.get call, we get a parsed xml document. So, to make Owl more convenient to use in that situation, we simply accept xml documents in addition to strings. --- package.json | 2 +- src/qweb/qweb.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 0541737f..b8c03b1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "owl", - "version": "0.18.0", + "version": "0.18.1", "description": "Odoo Web Library (OWL)", "main": "src/index.ts", "scripts": { diff --git a/src/qweb/qweb.ts b/src/qweb/qweb.ts index fac0fca5..6b850b3e 100644 --- a/src/qweb/qweb.ts +++ b/src/qweb/qweb.ts @@ -207,12 +207,12 @@ export class QWeb extends EventBus { } /** - * Load templates from a xml (as a string). This will look up for the first - * tag, and will consider each child of this as a template, with - * the name given by the t-name attribute. + * Load templates from a xml (as a string or xml document). This will look up + * for the first tag, and will consider each child of this as a + * template, with the name given by the t-name attribute. */ - addTemplates(xmlstr: string) { - const doc = parseXML(xmlstr); + addTemplates(xmlstr: string | Document) { + const doc = typeof xmlstr === 'string' ? parseXML(xmlstr) : xmlstr; const templates = doc.getElementsByTagName("templates")[0]; if (!templates) { return;