|
7 | 7 | <style> |
8 | 8 | :host { |
9 | 9 | display: table-row-group; |
10 | | - border-bottom: 1px solid #dbdbdb; |
| 10 | + |
11 | 11 | } |
12 | 12 | .tr { |
13 | 13 | display:table-row; |
|
198 | 198 | * Select an item from an event object. |
199 | 199 | */ |
200 | 200 | _selectionHandler(e) { |
201 | | - var m = e.path.find(entry => { |
| 201 | + let m = e.path.find(entry => { |
202 | 202 | return entry.classList && entry.classList.contains('tr'); |
203 | 203 | }); |
204 | | - var model = this.modelForElement(m); |
| 204 | + let model = this.modelForElement(m); |
205 | 205 | if (!model) { |
206 | 206 | return; |
207 | 207 | } |
208 | | - var modelTabIndex, activeElTabIndex; |
209 | | - var target = Polymer.dom(e).path[0]; |
210 | | - var activeEl = Polymer.dom(this.domHost ? this.domHost.root : document).activeElement; |
211 | | - var physicalItem = this._physicalItems[model[this.indexAs]]; |
| 208 | + let modelTabIndex, activeElTabIndex; |
| 209 | + let target = Polymer.dom(e).path[0]; |
| 210 | + let activeEl = Polymer.dom(this.domHost ? this.domHost.root : document).activeElement; |
| 211 | + let physicalItem = this._physicalItems[model[this.indexAs]]; |
212 | 212 | // Safari does not focus certain form controls via mouse |
213 | 213 | // https://bugs.webkit.org/show_bug.cgi?id=118043 |
214 | 214 | if (target.localName === 'input' || |
|
296 | 296 |
|
297 | 297 | _forwardItemPath(path, value) { |
298 | 298 | path = path.slice(6); // 'items.'.length == 6 |
299 | | - var dot = path.indexOf('.') + 1; |
| 299 | + let dot = path.indexOf('.') + 1; |
300 | 300 | if (dot === 0) { |
301 | 301 | dot = path.length; |
302 | 302 | } |
303 | | - var idx = parseInt(path.substring(0, dot), 10); |
304 | | - var offscreenItem = this._offscreenFocusedItem; |
| 303 | + let idx = parseInt(path.substring(0, dot), 10); |
| 304 | + let offscreenItem = this._offscreenFocusedItem; |
| 305 | + |
| 306 | + let inst = this.modelForElement(this._physicalItems[idx]); |
305 | 307 |
|
306 | | - var inst = this.modelForElement(this._physicalItems[idx]); |
307 | | - |
308 | 308 | if (!inst || inst[this.indexAs] !== idx) { |
309 | 309 | return; |
310 | 310 | } |
|
320 | 320 | * @param {number} size Size of the pool |
321 | 321 | */ |
322 | 322 | _createPool(size) { |
323 | | - var physicalItems = new Array(size); |
| 323 | + let physicalItems = new Array(size); |
324 | 324 | this._ensureTemplatized(); |
325 | | - for (var i = 0; i < size; i++) { |
326 | | - var inst = this.stamp(null); |
| 325 | + for (let i = 0; i < size; i++) { |
| 326 | + let inst = this.stamp(null); |
327 | 327 | // First element child is item; Safari doesn't support children[0] |
328 | 328 | // on a doc fragment. |
329 | 329 | physicalItems[i] = inst.root.querySelector('*'); |
|
336 | 336 | * Increases the pool size. |
337 | 337 | */ |
338 | 338 | _increasePool(poolSize) { |
339 | | - var ts = window.performance.now(); |
340 | 339 | // Concat arrays in place. |
341 | 340 | [].push.apply(this._physicalItems, this._createPool(poolSize)); |
342 | 341 | this._physicalCount = this._physicalItems.length; |
343 | 342 | this._update(); |
344 | | - this._templateCost = (window.performance.now() - ts); |
345 | 343 | } |
346 | 344 |
|
347 | 345 | /** |
|
351 | 349 | // Check if already templatized |
352 | 350 | if (!this.ctor) { |
353 | 351 | // Template instance props that should be excluded from forwarding |
354 | | - var props = {}; |
| 352 | + let props = {}; |
355 | 353 | props.__key__ = true; |
356 | 354 | props[this.as] = true; |
357 | 355 | props[this.indexAs] = true; |
|
383 | 381 | * @param {!Array<number>=} itemSet |
384 | 382 | */ |
385 | 383 | _assignModels(itemSet) { |
386 | | - var count = 0; |
| 384 | + let count = 0; |
387 | 385 | this._physicalItems.forEach((el) => { |
388 | | - var inst = this.modelForElement(el); |
389 | | - var item = this.items[count]; |
| 386 | + let inst = this.modelForElement(el); |
| 387 | + let item = this.items[count]; |
390 | 388 | if (item != null && item !== undefined) { |
391 | 389 | //inst.__key__ = this._collection ? this._collection.getKey(item) : null; |
392 | 390 | this._forwardProperty(inst, this.as, item); |
|
419 | 417 |
|
420 | 418 | _notifyInstancePropV2(inst, prop, value) { |
421 | 419 | if (Polymer.Path.matches(this.as, prop)) { |
422 | | - var idx = inst[this.indexAs]; |
| 420 | + let idx = inst[this.indexAs]; |
423 | 421 | if (prop == this.as) { |
424 | 422 | this.items[idx] = value; |
425 | 423 | } |
|
451 | 449 | this.clearSelection(); |
452 | 450 | } |
453 | 451 |
|
454 | | - var model = this.modelForElement(this._physicalItems[index]); |
| 452 | + let model = this.modelForElement(this._physicalItems[index]); |
455 | 453 | if (model) { |
456 | 454 | model[this.selectedAs] = true; |
457 | 455 | } |
|
494 | 492 | return; |
495 | 493 | } |
496 | 494 |
|
497 | | - var model = this.modelForElement(this._physicalItems[index]); |
| 495 | + let model = this.modelForElement(this._physicalItems[index]); |
498 | 496 | model[this.selectedAs] = false; |
499 | 497 |
|
500 | 498 | this.$.selector.deselectIndex(index); |
|
519 | 517 | * @param {Object} index The index of the item in the items array. |
520 | 518 | */ |
521 | 519 | toggleSelectionForIndex(index) { |
522 | | - var isSelected = this.$.selector.isIndexSelected |
| 520 | + let isSelected = this.$.selector.isIndexSelected |
523 | 521 | ? this.$.selector.isIndexSelected(index) : this.$.selector.isSelected(this.items[index]); |
524 | 522 | isSelected ? this.deselectIndex(index) : this.selectIndex(index); |
525 | 523 | } |
|
0 commit comments