Skip to content

Commit

Permalink
TypeScript Tagged template literals compiled incorrectly
Browse files Browse the repository at this point in the history
As discussed in bug microsoft/TypeScript#17956
TypeScript does a bad job compared to Babel when it comes
to transform tagget template literals.

Apparently users are ignoring this issue
#99
so this version of hyperHTML should fix it.
  • Loading branch information
WebReflection committed Sep 7, 2017
1 parent 529fec6 commit 38abc76
Show file tree
Hide file tree
Showing 7 changed files with 775 additions and 754 deletions.
2 changes: 1 addition & 1 deletion coverage/coverage.json

Large diffs are not rendered by default.

65 changes: 40 additions & 25 deletions coverage/lcov-report/hyperHTML/hyperhtml.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>567/567</span>
<span class='fraction'>568/568</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>332/332</span>
<span class='fraction'>326/326</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>92/92</span>
<span class='fraction'>94/94</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>548/548</span>
<span class='fraction'>550/550</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1314,7 +1314,12 @@ <h1>
1269
1270
1271
1272</td><td class="line-coverage quiet"><span class="cline-any cline-yes"></span>
1272
1273
1274
1275
1276
1277</td><td class="line-coverage quiet"><span class="cline-any cline-yes"></span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand Down Expand Up @@ -1840,6 +1845,15 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes">203×</span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes"></span>
Expand Down Expand Up @@ -2245,16 +2259,13 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-yes">203×</span>
<span class="cline-any cline-yes">203×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">76×</span>
Expand Down Expand Up @@ -2584,8 +2595,7 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes"></span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">var hyperHTML = (function (globalDocument) {'use strict';
<span class="cline-any cline-yes"></span></td><td class="text"><pre class="prettyprint lang-js">var hyperHTML = (function (globalDocument) {'use strict';
&nbsp;
/*! (c) 2017 Andrea Giammarchi @WebReflection, (ISC) */
&nbsp;
Expand Down Expand Up @@ -2801,7 +2811,7 @@ <h1>
var hyper = hypers.get(this);
if (
!hyper ||
hyper.template !== (FF ? unique(template) : template)
hyper.template !== TL(template)
) {
hyper = upgrade.apply(this, arguments);
hypers.set(this, hyper);
Expand Down Expand Up @@ -3107,6 +3117,15 @@ <h1>
&nbsp;
// beside IE, old WebKit browsers don't have `children` in DocumentFragment
var WK = !('children' in featureFragment);
&nbsp;
// both Firefox &lt; 55 and TypeScript have issues with template literals
// this lazy defined callback should spot issues right away
// and in the best case scenario become a no-op
var TL = function (template) {
if (template.propertyIsEnumerable('raw') || FF) TL = unique;
else TL = function (t) { return t; };
return TL(template);
};
&nbsp;
// ---------------------------------------------
// Helpers
Expand Down Expand Up @@ -3515,14 +3534,11 @@ <h1>
var transformers = {};
&nbsp;
// normalize Firefox issue with template literals
var templateObjects, unique;
if (FF) {
templateObjects = {};
unique = function (template) {
var key = '_' + template.join(UIDC);
return templateObjects[key] ||
(templateObjects[key] = template);
};
var templateObjects = {}, unique;
function unique(template) {
var key = '_' + template.join(UIDC);
return templateObjects[key] ||
(templateObjects[key] = template);
}
&nbsp;
// use native .append(...childNodes) where available
Expand Down Expand Up @@ -3750,7 +3766,7 @@ <h1>
// create a template, if unknown
// upgrade a node to use such template for future updates
function upgrade(template) {
if (FF) template = unique(template);
template = TL(template);
var updates;
var info = templates.get(template) ||
createTemplate.call(this, template);
Expand Down Expand Up @@ -3794,7 +3810,7 @@ <h1>
return type === 'adopt' ?
function adopt(statics) {
var args = arguments;
if (FF) statics = unique(statics);
statics = TL(statics);
if (template !== statics) {
setup = true;
template = statics;
Expand All @@ -3820,7 +3836,7 @@ <h1>
return adopter;
} :
function update(statics) {
if (FF) statics = unique(statics);
statics = TL(statics);
if (template !== statics) {
setup = true;
template = statics;
Expand Down Expand Up @@ -3855,14 +3871,13 @@ <h1>
}(document));
&nbsp;
// umd.KISS
try { module.exports = hyperHTML; } catch(o_O) {}
&nbsp;</pre></td></tr>
try { module.exports = hyperHTML; } catch(o_O) {}</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Sep 03 2017 10:41:35 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Sep 07 2017 09:41:12 GMT+0100 (BST)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
18 changes: 9 additions & 9 deletions coverage/lcov-report/hyperHTML/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>567/567</span>
<span class='fraction'>568/568</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>332/332</span>
<span class='fraction'>326/326</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>92/92</span>
<span class='fraction'>94/94</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>548/548</span>
<span class='fraction'>550/550</span>
</div>
</div>
</div>
Expand All @@ -62,13 +62,13 @@ <h1>
<td class="file high" data-value="hyperhtml.js"><a href="hyperhtml.js.html">hyperhtml.js</a></td>
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
<td data-value="100" class="pct high">100%</td>
<td data-value="567" class="abs high">567/567</td>
<td data-value="568" class="abs high">568/568</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="332" class="abs high">332/332</td>
<td data-value="326" class="abs high">326/326</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="92" class="abs high">92/92</td>
<td data-value="94" class="abs high">94/94</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="548" class="abs high">548/548</td>
<td data-value="550" class="abs high">550/550</td>
</tr>

</tbody>
Expand All @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Sep 03 2017 10:41:35 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Sep 07 2017 09:41:12 GMT+0100 (BST)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
18 changes: 9 additions & 9 deletions coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>567/567</span>
<span class='fraction'>568/568</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>332/332</span>
<span class='fraction'>326/326</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>92/92</span>
<span class='fraction'>94/94</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>548/548</span>
<span class='fraction'>550/550</span>
</div>
</div>
</div>
Expand All @@ -62,13 +62,13 @@ <h1>
<td class="file high" data-value="hyperHTML/"><a href="hyperHTML/index.html">hyperHTML/</a></td>
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
<td data-value="100" class="pct high">100%</td>
<td data-value="567" class="abs high">567/567</td>
<td data-value="568" class="abs high">568/568</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="332" class="abs high">332/332</td>
<td data-value="326" class="abs high">326/326</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="92" class="abs high">92/92</td>
<td data-value="94" class="abs high">94/94</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="548" class="abs high">548/548</td>
<td data-value="550" class="abs high">550/550</td>
</tr>

</tbody>
Expand All @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Sep 03 2017 10:41:35 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Sep 07 2017 09:41:12 GMT+0100 (BST)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
Loading

0 comments on commit 38abc76

Please sign in to comment.