Skip to content

Commit

Permalink
fix: disable sanitizer for amp custom styles
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 27, 2020
1 parent 4c3e2d5 commit 93a0964
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion templates/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
}<% } %>
}

0 comments on commit 93a0964

Please sign in to comment.