Skip to content

Commit 19f86b7

Browse files
committed
refactoring
1 parent 0541365 commit 19f86b7

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

frameworks/keyed/vanillajs-lite/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h1>VanillaJS-Lite-"keyed"</h1>
4444
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
4545
</div>
4646
</div>
47-
<template id="rowTemplate"><tr><td class="col-md-1">?</td><td class="col-md-4"><a>?</a></td><td class="col-md-1"><a><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td><td class="col-md-6"></td></tr></template>
47+
<template id="trow"><tr><td class="col-md-1">?</td><td class="col-md-4"><a>?</a></td><td class="col-md-1"><a><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td><td class="col-md-6"></td></tr></template>
4848
<script src="src/Main.js" type="module"></script>
4949
</body>
5050
</html>

frameworks/keyed/vanillajs-lite/src/Main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const pick = dict => dict[Math.round(Math.random() * 1000) % dict.length];
77
let ID = 1, rows = [], selection;
88
const ROW = Symbol(), ACTION = Symbol();
99

10-
const rowTemplate = document.querySelector('#rowTemplate').content.firstChild;
1110
const table = document.querySelector('table');
1211
let tbody = document.querySelector('tbody');
12+
const trow = document.querySelector('#trow');
1313

1414
const {cloneNode, insertBefore} = Node.prototype;
15-
const clone = (cloneNode.bind(rowTemplate, true));
15+
const clone = (cloneNode.bind(trow.content.firstChild, true));
1616
const insert = ((row, before = null) => insertBefore.call(tbody, row, before));
1717

1818
const build = (() => {
@@ -64,4 +64,3 @@ table.addEventListener('click', e => {
6464
let {target: t} = e;
6565
e.stopPropagation(), (t[ACTION] ?? (t = t.parentNode)[ACTION])?.(t[ROW]);
6666
});
67-

0 commit comments

Comments
 (0)