From 93a0964a59173d916681c2db347c5e183213f0b1 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Sun, 27 Dec 2020 21:32:03 +0330 Subject: [PATCH] fix: disable sanitizer for amp custom styles --- templates/plugin.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templates/plugin.js b/templates/plugin.js index 9aa5b3f5..653475c6 100644 --- a/templates/plugin.js +++ b/templates/plugin.js @@ -13,7 +13,12 @@ export default async function (ctx, inject) { Object.keys(result).forEach(key => inject(key, result[key])) } <% if (options.css) { %>if (ctx.$isAMP) { + const { head } = ctx.app + // Disable sanitizer + head.__dangerouslyDisableSanitizersByTagID = head.__dangerouslyDisableSanitizersByTagID || {} + head.__dangerouslyDisableSanitizersByTagID['amp-custom'] = ['innerHTML'] + const cssText = await import('!!raw-loader<%= options.cssLoader %>!<%= options.css %>').then(m => m.default || m) - ctx.app.head.style.push({ cssText, type: 'text/css', hid: 'amp-custom' }) + head.style.push({ cssText, type: 'text/css', hid: 'amp-custom' }) }<% } %> }