|
198 | 198 | * Select an item from an event object. |
199 | 199 | */ |
200 | 200 | _selectionHandler(e) { |
201 | | - console.log('_selectionHandler', e); |
202 | | - // debugger; |
203 | 201 | var m = e.path.find(entry => { |
204 | 202 | return entry.classList && entry.classList.contains('tr'); |
205 | 203 | }); |
|
238 | 236 |
|
239 | 237 | connectedCallback() { |
240 | 238 | super.connectedCallback(); |
241 | | - |
242 | | - console.log('connectedCallback'); |
243 | 239 | if (this._physicalCount === 0) { |
244 | | - this._debounceTemplate(this._render); |
| 240 | + this._debounceRender(this._render); |
245 | 241 | } |
246 | | - |
247 | 242 | } |
248 | 243 |
|
249 | 244 | _debounceRender(cb) { |
|
277 | 272 | * to `items`, splices or updates to a single item. |
278 | 273 | */ |
279 | 274 | _itemsChanged(change) { |
280 | | - console.log('_itemsChanged', change); |
281 | 275 | if (change.path === 'items') { |
282 | 276 | this.items = this.items || []; |
283 | 277 | this._physicalCount = this._physicalCount || 0; |
|
290 | 284 | }, this); |
291 | 285 | this._debounceRender(this._render); |
292 | 286 | } else { |
293 | | - this._forwardItemPath(change.path, change.value); |
| 287 | + if(change.path !== 'items.length') { |
| 288 | + this._forwardItemPath(change.path, change.value); |
| 289 | + } |
294 | 290 | } |
295 | 291 | } |
296 | 292 |
|
|
306 | 302 | } |
307 | 303 | var idx = parseInt(path.substring(0, dot), 10); |
308 | 304 | var offscreenItem = this._offscreenFocusedItem; |
309 | | - var isIndexRendered = this._isIndexRendered(idx); |
310 | | - var inst = this.modelForElement(this._physicalItems[this._getPhysicalIndex(idx)]); |
311 | 305 |
|
| 306 | + var inst = this.modelForElement(this._physicalItems[idx]); |
| 307 | + |
312 | 308 | if (!inst || inst[this.indexAs] !== idx) { |
313 | 309 | return; |
314 | 310 | } |
315 | 311 | path = path.substring(dot); |
316 | 312 | path = this.as + (path ? '.' + path : ''); |
317 | 313 | inst._setPendingPropertyOrPath(path, value, false, true); |
318 | 314 | inst._flushProperties && inst._flushProperties(true); |
319 | | - // TODO(blasten): V1 doesn't do this and it's a bug |
320 | | - if (isIndexRendered) { |
321 | | - this._updateMetrics([idx]); |
322 | | - this._positionItems(); |
323 | | - this._updateScrollerSize(); |
324 | | - } |
325 | 315 | } |
326 | 316 |
|
327 | 317 | /** |
|
330 | 320 | * @param {number} size Size of the pool |
331 | 321 | */ |
332 | 322 | _createPool(size) { |
333 | | - console.log('_createPool'); |
334 | 323 | var physicalItems = new Array(size); |
335 | 324 | this._ensureTemplatized(); |
336 | 325 | for (var i = 0; i < size; i++) { |
337 | 326 | var inst = this.stamp(null); |
338 | 327 | // First element child is item; Safari doesn't support children[0] |
339 | 328 | // on a doc fragment. |
340 | 329 | physicalItems[i] = inst.root.querySelector('*'); |
341 | | - console.log('_createPool', physicalItems[i]); |
342 | 330 | this.shadowRoot.appendChild(inst.root); |
343 | 331 | } |
344 | 332 | return physicalItems; |
|
396 | 384 | */ |
397 | 385 | _assignModels(itemSet) { |
398 | 386 | var count = 0; |
399 | | - console.log('_assignModels, ', this._physicalItems, this._physicalCount); |
400 | 387 | this._physicalItems.forEach((el) => { |
401 | 388 | var inst = this.modelForElement(el); |
402 | 389 | var item = this.items[count]; |
|
421 | 408 |
|
422 | 409 | /* Templatizer bindings for v2 */ |
423 | 410 | _forwardHostPropV2(prop, value) { |
424 | | - console.log('_forwardHostPropV2', prop, value); |
425 | 411 | (this._physicalItems || []) |
426 | 412 | .concat([this._offscreenFocusedItem, this._focusBackfillItem]) |
427 | 413 | .forEach(function(item) { |
|
432 | 418 | } |
433 | 419 |
|
434 | 420 | _notifyInstancePropV2(inst, prop, value) { |
435 | | - console.log('_notifyInstancePropV2', inst, prop, value); |
436 | 421 | if (Polymer.Path.matches(this.as, prop)) { |
437 | 422 | var idx = inst[this.indexAs]; |
438 | 423 | if (prop == this.as) { |
|
449 | 434 | * @param {Object} item The item instance. |
450 | 435 | */ |
451 | 436 | selectItem(item) { |
452 | | - console.log('selectItem', item); |
453 | 437 | return this.selectIndex(this.items.indexOf(item)); |
454 | 438 | } |
455 | 439 |
|
|
460 | 444 | * @param {Object} index The item instance. |
461 | 445 | */ |
462 | 446 | selectIndex(index) { |
463 | | - |
464 | | - console.log('selectIndex', index, this.multiSelection,this.selectedItem); |
465 | 447 | if (index < 0 || index >= this.items) { |
466 | 448 | return; |
467 | 449 | } |
|
475 | 457 | } |
476 | 458 |
|
477 | 459 | this.$.selector.selectIndex(index); |
478 | | - |
479 | 460 | } |
480 | 461 |
|
481 | 462 | /** |
|
484 | 465 | * @method clearSelection |
485 | 466 | */ |
486 | 467 | clearSelection() { |
487 | | - console.log('clearSelection'); |
488 | 468 | if(this._physicalItems) { |
489 | 469 | this._physicalItems.map((el) => { |
490 | 470 | this.modelForElement(el)[this.selectedAs] = false; |
|
500 | 480 | * @param {Object} item The item instance. |
501 | 481 | */ |
502 | 482 | deselectItem(item) { |
503 | | - console.log('deselectItem', item); |
504 | 483 | return this.deselectIndex(this.items.indexOf(item)); |
505 | 484 | } |
506 | 485 |
|
|
540 | 519 | * @param {Object} index The index of the item in the items array. |
541 | 520 | */ |
542 | 521 | toggleSelectionForIndex(index) { |
543 | | - console.log('toggleSelectionForIndex', index, this.$.selector.isIndexSelected(index)); |
544 | 522 | var isSelected = this.$.selector.isIndexSelected |
545 | 523 | ? this.$.selector.isIndexSelected(index) : this.$.selector.isSelected(this.items[index]); |
546 | | - console.log('isSelected', isSelected); |
547 | 524 | isSelected ? this.deselectIndex(index) : this.selectIndex(index); |
548 | 525 | } |
549 | 526 |
|
|
0 commit comments