* Upgrades the element to the provided new implementation. If element * has already been attached, it's layout validation and attachment flows * are repeated for the new implementation. * @param {typeof ./base-element.BaseElement} newImplClass * @final @package
(newImplClass)
| 361 | * @final @package |
| 362 | */ |
| 363 | upgrade(newImplClass) { |
| 364 | if (this.isInTemplate_) { |
| 365 | return; |
| 366 | } |
| 367 | if (this.upgradeState_ != UpgradeState_Enum.NOT_UPGRADED) { |
| 368 | // Already upgraded or in progress or failed. |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | this.implClass_ = newImplClass; |
| 373 | this.signals_.signal(CommonSignals_Enum.READY_TO_UPGRADE); |
| 374 | if (this.everAttached) { |
| 375 | // Usually, we do an implementation upgrade when the element is |
| 376 | // attached to the DOM. But, if it hadn't yet upgraded from |
| 377 | // ElementStub, we couldn't. Now that it's upgraded from a stub, go |
| 378 | // ahead and do the full upgrade. |
| 379 | this.upgradeOrSchedule_(); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * When the document is ready (meaning all external resources are loaded or |
no test coverage detected