Skip to content

Commit d8c6969

Browse files
committed
Make templates work when they have attributes
1 parent 94803aa commit d8c6969

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

codepen-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var scriptRegExp = /<script\s([^>]+)>([\s\S]*?)<\/script>/ig;
22
var styleRegExp = /<style>([\s\S]*?)<\/style>/i;
3-
var templateRegExp = /<template>([\s\S]*?)<\/template>/ig;
3+
var templateRegExp = /<template\s?([^>]+)?>([\s\S]*?)<\/template>/ig;
44
var moduleTest = /type=["']([\w\/]+)["']/;
55
var srcTest = /src=/;
66
var DEFAULT_EDITORS = "0011";

test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,22 @@ describe("bit-docs-html-codepen-link", function() {
185185
</template>
186186
`.trim());
187187
});
188+
189+
it("Does not remove styles2", function() {
190+
var data = codepenData.html(`
191+
<template id="tmpl">
192+
<style>
193+
</style>
194+
<div class="gmap"></div>
195+
</template>
196+
<script type="module"></script>`);
197+
198+
var html = data.html.trim();
199+
assert.ok(/style/.test(html));
200+
assert.equal(html, `<template id="tmpl">
201+
<style>
202+
</style>
203+
<div class="gmap"></div>
204+
</template>`)
205+
});
188206
});

0 commit comments

Comments
 (0)