* Ensure that the element is eagerly loaded. * * @param {number=} opt_parentPriority * @return {!Promise} * @final
(opt_parentPriority)
| 788 | * @final |
| 789 | */ |
| 790 | ensureLoaded(opt_parentPriority) { |
| 791 | return this.mount().then(() => { |
| 792 | if (this.R1()) { |
| 793 | if (this.implClass_.usesLoading(this)) { |
| 794 | this.impl_.ensureLoaded(); |
| 795 | } |
| 796 | return this.whenLoaded(); |
| 797 | } |
| 798 | |
| 799 | // Very ugly! The "built" signal must be resolved from the Resource |
| 800 | // and not the element itself because the Resource has not correctly |
| 801 | // set its state for the downstream to process it correctly. |
| 802 | const resource = this.getResource_(); |
| 803 | return resource.whenBuilt().then(() => { |
| 804 | if (resource.getState() == ResourceState_Enum.LAYOUT_COMPLETE) { |
| 805 | return; |
| 806 | } |
| 807 | if ( |
| 808 | resource.getState() != ResourceState_Enum.LAYOUT_SCHEDULED || |
| 809 | resource.isMeasureRequested() |
| 810 | ) { |
| 811 | resource.measure(); |
| 812 | } |
| 813 | if (!resource.isDisplayed()) { |
| 814 | return; |
| 815 | } |
| 816 | this.getResources().scheduleLayoutOrPreload( |
| 817 | resource, |
| 818 | /* layout */ true, |
| 819 | opt_parentPriority, |
| 820 | /* forceOutsideViewport */ true |
| 821 | ); |
| 822 | return this.whenLoaded(); |
| 823 | }); |
| 824 | }); |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * See `BaseElement.setAsContainer`. |
nothing calls this directly
no test coverage detected