From e728eb8c6ed1b08f43f822aced31260c9545bc25 Mon Sep 17 00:00:00 2001 From: Tom Medema Date: Thu, 12 Apr 2018 10:02:06 -0700 Subject: [PATCH] allow for multiple at-rules --- src/css_composer/index.js | 9 +++++++-- test/specs/grapesjs/index.js | 1 + test/specs/parser/model/ParserHtml.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/css_composer/index.js b/src/css_composer/index.js index 1a5dd374d..3443780cb 100644 --- a/src/css_composer/index.js +++ b/src/css_composer/index.js @@ -182,8 +182,13 @@ module.exports = () => { var w = width || ''; var opt = { ...opts }; var rule = this.get(selectors, s, w, opt); - if (rule) return rule; - else { + + // do not create rules that were found before + // unless this is an at-rule, for which multiple declarations + // make sense (e.g. multiple `@font-type`s) + if (rule && rule.config && !rule.config.atRuleType) { + return rule; + } else { opt.state = s; opt.mediaText = w; opt.selectors = ''; diff --git a/test/specs/grapesjs/index.js b/test/specs/grapesjs/index.js index 0169123bb..c4ad136d1 100644 --- a/test/specs/grapesjs/index.js +++ b/test/specs/grapesjs/index.js @@ -166,6 +166,7 @@ describe('GrapesJS', () => { @font-face { font-family: 'Glyphicons Halflings'; src: url(https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/fonts/glyphicons-halflings-regular.woff2) format('woff2'); + } @font-face { font-family: 'Droid Sans'; src: url(https://fonts.gstatic.com/s/droidsans/v8/SlGVmQWMvZQIdix7AFxXkHNSbRYXags.woff2) format('woff2'); diff --git a/test/specs/parser/model/ParserHtml.js b/test/specs/parser/model/ParserHtml.js index 11e01bb91..683c1afa1 100644 --- a/test/specs/parser/model/ParserHtml.js +++ b/test/specs/parser/model/ParserHtml.js @@ -372,7 +372,7 @@ module.exports = { expect(res.css).toEqual(resCss); }); - it.only('Respect multiple font-faces contained in styles in html', () => { + it('Respect multiple font-faces contained in styles in html', () => { const str = `