@@ -233,28 +233,25 @@ class BenchmarkRow extends HTMLTableRowElement {
233233 this . _rowLabel = null ;
234234 this . _rowSelected = false ;
235235
236- const td1 = this . _td1 = td ( " col-md-1" ) ;
236+ const tds = [ 'col-md-1' , ' col-md-4' , 'col-md-1' , 'col-md-6' ] . map ( td ) ;
237237
238- const td2 = td ( "col-md-4" ) ;
239- const a2 = this . _a2 = document . createElement ( "a" ) ;
240- td2 . appendChild ( a2 ) ;
238+ const a2 = document . createElement ( 'a' ) ;
239+ tds [ 1 ] . appendChild ( a2 ) ;
241240
242- const td3 = td ( "col-md-1" ) ;
243- const a = document . createElement ( "a" ) ;
241+ const a3 = document . createElement ( 'a' ) ;
242+ a3 . classList . add ( 'remove' ) ;
243+ const a3Span = document . createElement ( 'span' ) ;
244+ a3Span . classList . add ( 'glyphicon' , 'glyphicon-remove' ) ;
245+ a3Span . setAttribute ( 'aria-hidden' , 'true' ) ;
246+ a3 . appendChild ( a3Span ) ;
247+ tds [ 2 ] . appendChild ( a3 ) ;
244248
245- const span = document . createElement ( "span" ) ;
246- span . className = "glyphicon glyphicon-remove" ;
247- span . setAttribute ( "aria-hidden" , "true" ) ;
249+ this . _idContainer = tds [ 0 ] ;
250+ this . _labelContainer = a2 ;
248251
249- a . appendChild ( span ) ;
250- td3 . appendChild ( a ) ;
252+ this . append ( ...tds ) ;
251253
252- this . appendChild ( td1 ) ;
253- this . appendChild ( td2 ) ;
254- this . appendChild ( td3 ) ;
255- this . appendChild ( td ( "col-md-6" ) ) ;
256-
257- a . addEventListener ( "click" , ( ev ) => {
254+ a3 . addEventListener ( "click" , ( ev ) => {
258255 ev . preventDefault ( ) ;
259256 this . dispatchEvent ( new CustomEvent ( "benchmark-action" , {
260257 bubbles : true ,
@@ -276,15 +273,15 @@ class BenchmarkRow extends HTMLTableRowElement {
276273 }
277274
278275 set rowId ( v ) {
279- this . _td1 . textContent = this . _rowId = v ;
276+ this . _idContainer . textContent = this . _rowId = v ;
280277 }
281278
282279 get rowLabel ( ) {
283280 return this . _rowLabel ;
284281 }
285282
286283 set rowLabel ( v ) {
287- this . _a2 . textContent = this . _rowLabel = v ;
284+ this . _labelContainer . textContent = this . _rowLabel = v ;
288285 }
289286
290287 get rowSelected ( ) {
@@ -299,18 +296,17 @@ class BenchmarkRow extends HTMLTableRowElement {
299296 }
300297}
301298
299+ /**
300+ * @localvoid :
301+ *
302+ * There are two ways how to instantiate WebComponents: with a `new` operator and with `document.createElement()`
303+ * function. Instantiating WebComponents with a `new` operator has a slightly less overhead (probably because it
304+ * doesn't involve a hash map lookup to find a component).
305+ *
306+ * The main reason why I've used `document.createElement()` here is because it is an idiomatic way to instantiate
307+ * components in all popular frameworks that use WebComponents.
308+ */
302309function createRow ( data ) {
303- /**
304- * @localvoid :
305- *
306- * There are two ways how to instantiate WebComponents: with a `new` operator and with `document.createElement()`
307- * function. Instantiating WebComponents with a `new` operator has a slightly less overhead (probably because it
308- * doesn't involve a hash map lookup to find a component).
309- *
310- * The main reason why I've used `document.createElement()` here is because it is an idiomatic way to instantiate
311- * components in all popular frameworks that use WebComponents.
312- */
313- // const e = new BenchmarkRow();
314310 const e = document . createElement ( "tr" , { is : "benchmark-row" } ) ;
315311 e . rowId = data . id ;
316312 e . rowLabel = data . label ;
0 commit comments