Skip to content

Commit

Permalink
chore(style): fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
potato4d committed Jan 4, 2021
1 parent 2b241f5 commit 3cf5d8d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,19 @@ function registerRendererHook (options) {
*/
params.HEAD = params.HEAD
.replace(/<style[^>]*>[.\S\s]*?<\/style>/g, v => v.includes('amp-custom') ? v : '')
.replace(/<\/style>[\S\s]*<style[^>]*>/g, '')
} else {
/**
* Merge inline styles
*/
const styleRegex = /<style(?: .+?)?>([\s\S]*?)<\/style>/g
const styleList = params.HEAD.match(styleRegex).map((css) => {
const rawStyle = css.replace(styleRegex, '$1\n')
return rawStyle
})
params.HEAD = params.HEAD.replace(styleRegex, '') + `<style>${styleList.join('\n')}</style>`
}

const styleRegex = /<style(?: .+?)?>([\s\S]*?)<\/style>/g
const styleList = params.HEAD.match(styleRegex).map((css) => {
const rawStyle = css.replace(styleRegex, '$1\n')
return rawStyle
})
params.HEAD = params.HEAD.replace(styleRegex, '') + `<style>${styleList.join('\n')}</style>`

/**
* Mark styles as `amp-custom`
*/
Expand Down

0 comments on commit 3cf5d8d

Please # to comment.