Skip to content
Navigation Menu
{{ message }}
forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase-element.js
More file actions
812 lines (740 loc) · 25.2 KB
/
Copy pathbase-element.js
File metadata and controls
812 lines (740 loc) · 25.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
/**
* Copyright 2015 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Layout} from './layout';
import {loadPromise} from './event-helper';
import {preconnectForElement} from './preconnect';
import {isArray} from './types';
import {viewportForDoc} from './viewport';
import {vsyncFor} from './vsync';
import {user} from './log';
/**
* Base class for all custom element implementations. Instead of inheriting
* from Element this class has an Element. Among other things this allows
* switching the element implementation when going from a stub to the full
* implementation.
*
* The base class implements a set of lifecycle methods that are called by
* the runtime as appropriate. These are mostly based on the custom element
* lifecycle (See
* http://www.html5rocks.com/en/tutorials/webcomponents/customelements/)
* and adding AMP style late loading to the mix.
*
* The complete lifecycle of custom DOM element is:
*
* ||
* || createdCallback
* ||
* \/
* State: <NOT BUILT> <NOT UPGRADED> <NOT ATTACHED>
* ||
* || upgrade
* ||
* \/
* State: <NOT BUILT> <NOT ATTACHED>
* ||
* || firstAttachedCallback
* ||
* \/
* State: <NOT BUILT>
* ||
* || buildCallback
* || !getPlaceholder() => createPlaceholderCallback
* || preconnectCallback may be called N times after this, but only
* || after the doc becomes visible.
* || pauseCallback may be called N times after this.
* || resumeCallback may be called N times after this.
* ||
* \/
* State: <BUILT>
* ||
* || layoutCallback <==
* || (firstLayoutCompleted) ||
* || ||
* \/ || isRelayoutNeeded?
* State: <LAID OUT> ||
* || ||
* || =========
* ||
* || viewportCallback
* || unlayoutCallback may be called N times after this.
* ||
* \/
* State: <IN VIEWPORT>
*
* The preconnectCallback is called when the systems thinks it is good
* to preconnect to hosts needed by an element. It will never be called
* before buildCallback and it might be called multiple times including
* after layoutCallback.
*
* The pauseCallback is called when when the document becomes inactive, e.g.
* when the user swipes away from the document, or when the element is no
* longer being displayed, e.g. when the carousel slide slides out of view.
* In these situations, any actively playing media should pause.
*
* The resumeCallback is called when when the document becomes active again
* after becoming inactive, e.g. when the user swipes away from the document
* and swipes back. In these situations, any paused media may begin playing
* again, if user interaction is not required.
* TODO(jridgewell) slide slides into view
*
* The createPlaceholderCallback is called if AMP didn't detect a provided
* placeholder for the element, subclasses can override this to build and
* return a dynamically created placeholder that AMP would append to the
* element.
*
* The unlayoutCallback is called when the document becomes inactive, e.g.
* when the user swipes away from the document, or another tab is focused.
* In these situations, expensive memory and CPU resources should be freed.
*
* Additionally whenever the dimensions of an element might have changed
* AMP remeasures its dimensions and calls `onLayoutMeasure` on the
* element instance. This can be used to do additional style calculations
* without triggering style recalculations.
*
* For more details, see {@link custom-element.js}.
*
* Each method is called exactly once and overriding them in subclasses
* is optional.
*/
export class BaseElement {
/** @param {!AmpElement} element */
constructor(element) {
/** @public @const {!Element} */
this.element = element;
/*
\ \ / \ / / / \ | _ \ | \ | | | | | \ | | / _____|
\ \/ \/ / / ^ \ | |_) | | \| | | | | \| | | | __
\ / / /_\ \ | / | . ` | | | | . ` | | | |_ |
\ /\ / / _____ \ | |\ \----.| |\ | | | | |\ | | |__| |
\__/ \__/ /__/ \__\ | _| `._____||__| \__| |__| |__| \__| \______|
Any private property for BaseElement should be declared in
build-system/amp.extern.js, this is so closure compiler doesn't reuse the
same symbol it would use in the core compilation unit for the private
property in the extensions compilation unit's private properties.
*/
/** @package {!Layout} */
this.layout_ = Layout.NODISPLAY;
/** @package {number} */
this.layoutWidth_ = -1;
/** @package {boolean} */
this.inViewport_ = false;
/** @public @const {!Window} */
this.win = element.ownerDocument.defaultView;
/** @private {?Object<string, function(!./service/action-impl.ActionInvocation)>} */
this.actionMap_ = null;
/** @public {!./preconnect.Preconnect} */
this.preconnect = preconnectForElement(this.element);
/** @public {?Object} For use by sub classes */
this.config = null;
}
/**
* This is the priority of loading elements (layoutCallback).
* The lower the number, the higher the priority.
* The default priority for base elements is 0.
* @return {number}
*/
getPriority() {
return 0;
}
/** @return {!Layout} */
getLayout() {
return this.layout_;
}
/**
* Returns a previously measured layout box of the element.
* @return {!./layout-rect.LayoutRectDef}
*/
getLayoutBox() {
return this.element.getLayoutBox();
}
/**
* DO NOT CALL. Retained for backward compat during rollout.
* @public @return {!Window}
*/
getWin() {
return this.win;
}
/**
* Returns the associated ampdoc. Only available when `buildCallback` and
* going forward. It throws an exception before `buildCallback`.
* @return {!./service/ampdoc-impl.AmpDoc}
*/
getAmpDoc() {
return this.element.getAmpDoc();
}
/** @public @return {!./service/vsync-impl.Vsync} */
getVsync() {
return vsyncFor(this.win);
}
/**
* Returns the layout width for this element. A `-1` value indicates that the
* layout is not yet known. A `0` value indicates that the element is not
* visible.
* @return {number}
* @public
*/
getLayoutWidth() {
return this.layoutWidth_;
}
/**
* Intended to be implemented by subclasses. Tests whether the element
* supports the specified layout. By default only Layout.NODISPLAY is
* supported.
* @param {!Layout} layout
* @return {boolean}
* @public
*/
isLayoutSupported(layout) {
return layout == Layout.NODISPLAY;
}
/**
* Intended to be implemented by subclasses. Tests whether the element
* requires fixed positioning.
* @return {boolean}
* @public
*/
isAlwaysFixed() {
return false;
}
/**
* @return {boolean}
*/
isInViewport() {
return this.inViewport_;
}
/**
* This method is called when the element is added to DOM for the first time
* and before `buildCallback` to give the element a chance to redirect its
* implementation to another `BaseElement` implementation. The returned
* value can be either `null` or `undefined` to indicate that no redirection
* will take place; `BaseElement` instance to upgrade immediately; or a
* promise to upgrade with the resolved `BaseElement` instance.
*
* Notice that calls to `upgradeCallback` are not recursive. I.e. this
* callback will not be called on the returned instance again.
*
* @return {!BaseElement|!Promise<!BaseElement>|null}
*/
upgradeCallback() {
// Subclasses may override.
return null;
}
/**
* Called when the element is first created. Note that for element created
* using createElement this may be before any children are added.
*/
createdCallback() {
// Subclasses may override.
}
/**
* Override in subclass to adjust the element when it is being added to the
* DOM. Could e.g. be used to insert a fallback. Should not typically start
* loading a resource.
*/
firstAttachedCallback() {
// Subclasses may override.
}
/**
* Override in subclass if the element needs to rebuilt its DOM content.
* Until the element has been rebuilt its content are not shown with an only
* exception of [placeholder] elements. From the moment the element is created
* and until the building phase is complete it will have "amp-notbuilt" CSS
* class set on it.
*
* This callback is executed early after the element has been attached to DOM.
*/
buildCallback() {
// Subclasses may override.
}
/**
* Called by the framework to give the element a chance to preconnect to
* hosts and prefetch resources it is likely to need. May be called
* multiple times because connections can time out.
* @param {boolean=} opt_onLayout
*/
preconnectCallback(opt_onLayout) {
// Subclasses may override.
}
/**
* Override in subclass to adjust the element when it is being removed from
* the DOM. Could e.g. be used to remove a listener.
*/
detachedCallback() {
// Subclasses may override.
}
/**
* Sets this element as the owner of the specified element. By setting itself
* as an owner, the element declares that it will manage the lifecycle of
* the owned element itself. This element, as an owner, will have to call
* {@link scheduleLayout}, {@link schedulePreload}, {@link updateInViewport}
* and similar methods.
* @param {!Element} element
*/
setAsOwner(element) {
this.element.getResources().setOwner(element, this.element);
}
/**
* Subclasses can override this method to opt-in into being called to
* prerender when document itself is not yet visible (pre-render mode).
* @return {boolean}
*/
prerenderAllowed() {
return false;
}
/**
* Subclasses can override this method to create a dynamic placeholder
* element and return it to be appended to the element. This will only
* be called if the element doesn't already have a placeholder.
* @returns {?Element}
*/
createPlaceholderCallback() {
return null;
}
/**
* Subclasses can override this method to opt-out of rendering the element
* when it is not currently visible.
* Returning a boolean allows or prevents rendering outside the viewport at
* any distance, while returning a positive number allows rendering only when
* the element is within X viewports of the current viewport. Returning a
* zero causes the element to only render inside the viewport.
* @return {boolean|number}
*/
renderOutsideViewport() {
return 3;
}
/**
* Subclasses can override this method to opt-in into receiving additional
* {@link layoutCallback} calls. Note that this method is not consulted for
* the first layout given that each element must be laid out at least once.
* @return {boolean}
*/
isRelayoutNeeded() {
return false;
}
/**
* Called when the element should perform layout. At this point the element
* should load/reload resources associated with it. This method is called
* by the runtime and cannot be called manually. Returns promise that will
* complete when loading is considered to be complete.
*
* The first layout call is always called. If the subclass is interested in
* receiving additional callbacks, it has to opt in to do so using
* {@link isRelayoutNeeded} method.
*
* @return {!Promise}
*/
layoutCallback() {
return Promise.resolve();
}
/**
* Called to notify the element that the first layout has been successfully
* completed.
*
* The default behavior of this method is to hide the placeholder. However,
* a subclass may choose to hide placeholder earlier or not hide it at all.
*
* @public
*/
firstLayoutCompleted() {
this.togglePlaceholder(false);
}
/**
* Instructs the resource that it has either entered or exited the visible
* viewport. Intended to be implemented by actual components.
* @param {boolean} unusedInViewport
*/
viewportCallback(unusedInViewport) {
}
/**
* Requests the element to stop its activity when the document goes into
* inactive state. The scope is up to the actual component. Among other
* things the active playback of video or audio content must be stopped.
*/
pauseCallback() {
}
/**
* Requests the element to resume its activity when the document returns from
* an inactive state. The scope is up to the actual component. Among other
* things the active playback of video or audio content may be resumed.
*/
resumeCallback() {
}
/**
* Requests the element to unload any expensive resources when the element
* goes into non-visible state. The scope is up to the actual component.
* The component must return `true` if it'd like to later receive
* {@link layoutCallback} in case document becomes active again.
*
* @return {boolean}
*/
unlayoutCallback() {
return false;
}
/**
* Subclasses can override this method to opt-in into calling
* {@link unlayoutCallback} when paused.
* @return {boolean}
*/
unlayoutOnPause() {
return false;
}
/**
* Instructs the element that its activation is requested based on some
* user event. Intended to be implemented by actual components.
* @param {!./service/action-impl.ActionInvocation} unusedInvocation
*/
activate(unusedInvocation) {
}
/**
* Returns a promise that will resolve or fail based on the element's 'load'
* and 'error' events. Optionally this method takes a timeout, which will reject
* the promise if the resource has not loaded by then.
* @param {T} element
* @param {number=} opt_timeout
* @return {!Promise<T>}
* @template T
* @final
*/
loadPromise(element, opt_timeout) {
return loadPromise(element, opt_timeout);
}
initActionMap_() {
if (!this.actionMap_) {
this.actionMap_ = this.win.Object.create(null);
}
}
/**
* Registers the action handler for the method with the specified name.
* @param {string} method
* @param {function(!./service/action-impl.ActionInvocation)} handler
* @public
*/
registerAction(method, handler) {
this.initActionMap_();
this.actionMap_[method] = handler;
}
/**
* Requests the element to execute the specified method. If method must have
* been previously registered using {@link registerAction}, otherwise an
* error is thrown.
* @param {!./service/action-impl.ActionInvocation} invocation The invocation data.
* @param {boolean} unusedDeferred Whether the invocation has had to wait any time
* for the element to be resolved, upgraded and built.
* @final
* @package
*/
executeAction(invocation, unusedDeferred) {
if (invocation.method == 'activate') {
this.activate(invocation);
} else {
this.initActionMap_();
const handler = this.actionMap_[invocation.method];
user().assert(handler, `Method not found: ${invocation.method} in %s`,
this);
handler(invocation);
}
}
/**
* Returns the maximum DPR available on this device.
* @return {number}
*/
getMaxDpr() {
return this.element.getResources().getMaxDpr();
}
/**
* Returns the most optimal DPR currently recommended.
* @return {number}
*/
getDpr() {
return this.element.getResources().getDpr();
}
/**
* Utility method that propagates attributes from this element
* to the given element.
* @param {string|!Array<string>} attributes
* @param {!Element} element
* @public @final
*/
propagateAttributes(attributes, element) {
attributes = isArray(attributes) ? attributes : [attributes];
for (let i = 0; i < attributes.length; i++) {
const attr = attributes[i];
if (!this.element.hasAttribute(attr)) {
continue;
}
element.setAttribute(attr, this.element.getAttribute(attr));
}
}
/**
* Utility method that forwards the given list of non-bubbling events
* from the given element to this element as custom events with the same name.
* @param {string|!Array<string>} events
* @param {!Element} element
* @public @final
*/
forwardEvents(events, element) {
events = isArray(events) ? events : [events];
for (let i = 0; i < events.length; i++) {
element.addEventListener(events[i], event => {
this.element.dispatchCustomEvent(events[i], event.data || {});
});
}
}
/**
* Returns an optional placeholder element for this custom element.
* @return {?Element}
* @public @final
*/
getPlaceholder() {
return this.element.getPlaceholder();
}
/**
* Hides or shows the placeholder, if available.
* @param {boolean} state
* @public @final
*/
togglePlaceholder(state) {
this.element.togglePlaceholder(state);
}
/**
* Returns an optional fallback element for this custom element.
* @return {?Element}
* @public @final
*/
getFallback() {
return this.element.getFallback();
}
/**
* Hides or shows the fallback, if available. This function must only
* be called inside a mutate context.
* @param {boolean} state
* @public @final
*/
toggleFallback(state) {
this.element.toggleFallback(state);
}
/**
* Returns an optional overflow element for this custom element.
* @return {?Element}
* @public @final
*/
getOverflowElement() {
return this.element.getOverflowElement();
}
/**
* Returns the original nodes of the custom element without any service nodes
* that could have been added for markup. These nodes can include Text,
* Comment and other child nodes.
* @return {!Array<!Node>}
* @public @final
*/
getRealChildNodes() {
return this.element.getRealChildNodes();
}
/**
* Returns the original children of the custom element without any service
* nodes that could have been added for markup.
* @return {!Array<!Element>}
* @public @final
*/
getRealChildren() {
return this.element.getRealChildren();
}
/**
* Configures the supplied element to have a "fill content" layout. The
* exact interpretation of "fill content" depends on the element's layout.
*
* If `opt_replacedContent` is specified, it indicates whether the "replaced
* content" styling should be applied. Replaced content is not allowed to
* have its own paddings or border.
*
* @param {!Element} element
* @param {boolean=} opt_replacedContent
* @public @final
*/
applyFillContent(element, opt_replacedContent) {
element.classList.add('-amp-fill-content');
if (opt_replacedContent) {
element.classList.add('-amp-replaced-content');
}
}
/**
* Returns the viewport within which the element operates.
* @return {!./service/viewport-impl.Viewport}
*/
getViewport() {
return viewportForDoc(this.getAmpDoc());
}
/**
* Returns the layout rectangle of the element used for reporting this
* element's intersection with the viewport.
* @return {!./layout-rect.LayoutRectDef}
*/
getIntersectionElementLayoutBox() {
return this.getLayoutBox();
}
/**
* Schedule the layout request for the children element or elements
* specified. Resource manager will perform the actual layout based on the
* priority of this element and its children.
* @param {!Element|!Array<!Element>} elements
* @public
*/
scheduleLayout(elements) {
this.element.getResources().scheduleLayout(this.element, elements);
}
/**
* @param {!Element|!Array<!Element>} elements
* @public
*/
schedulePause(elements) {
this.element.getResources().schedulePause(this.element, elements);
}
/**
* @param {!Element|!Array<!Element>} elements
* @public
*/
scheduleResume(elements) {
this.element.getResources().scheduleResume(this.element, elements);
}
/**
* Schedule the preload request for the children element or elements
* specified. Resource manager will perform the actual preload based on the
* priority of this element and its children.
* @param {!Element|!Array<!Element>} elements
* @public
*/
schedulePreload(elements) {
this.element.getResources().schedulePreload(this.element, elements);
}
/**
* @param {!Element|!Array<!Element>} elements
* @public
*/
scheduleUnlayout(elements) {
this.element.getResources()./*OK*/scheduleUnlayout(this.element, elements);
}
/**
* Update inViewport state of the specified children element or elements.
* Resource manager will perform the actual changes to the inViewport state
* based on the state of these elements and their parent subtree.
* @param {!Element|!Array<!Element>} elements
* @param {boolean} inLocalViewport
* @public
*/
updateInViewport(elements, inLocalViewport) {
this.element.getResources().updateInViewport(
this.element, elements, inLocalViewport);
}
/**
* Requests the runtime to update the height of this element to the specified
* value. The runtime will schedule this request and attempt to process it
* as soon as possible.
* @param {number} newHeight
* @public
*/
changeHeight(newHeight) {
this.element.getResources()./*OK*/changeSize(
this.element, newHeight, /* newWidth */ undefined);
}
/**
* Return a promise that requests the runtime to update
* the height of this element to the specified value.
* The runtime will schedule this request and attempt to process it
* as soon as possible. However, unlike in {@link changeHeight}, the runtime
* may refuse to make a change in which case it will show the element's
* overflow element if provided, which is supposed to provide the reader with
* the necessary user action. (The overflow element is shown only if the
* requested height is greater than 0.)
* The promise is resolved if the height is successfully updated.
* @param {number} newHeight
* @return {!Promise}
* @public
*/
attemptChangeHeight(newHeight) {
return this.element.getResources().attemptChangeSize(
this.element, newHeight, /* newWidth */ undefined);
}
/**
* Return a promise that requests the runtime to update
* the size of this element to the specified value.
* The runtime will schedule this request and attempt to process it
* as soon as possible. However, unlike in {@link changeSize}, the runtime
* may refuse to make a change in which case it will show the element's
* overflow element if provided, which is supposed to provide the reader with
* the necessary user action. (The overflow element is shown only if the
* requested height is greater than 0.)
* The promise is resolved if the height is successfully updated.
* @param {number|undefined} newHeight
* @param {number|undefined} newWidth
* @return {!Promise}
* @public
*/
attemptChangeSize(newHeight, newWidth) {
return this.element.getResources().attemptChangeSize(
this.element, newHeight, newWidth);
}
/**
* Runs the specified mutation on the element and ensures that measures
* and layouts performed for the affected elements.
*
* This method should be called whenever a significant mutations are done
* on the DOM that could affect layout of elements inside this subtree or
* its siblings. The top-most affected element should be specified as the
* first argument to this method and all the mutation work should be done
* in the mutator callback which is called in the "mutation" vsync phase.
*
* @param {function()} mutator
* @param {Element=} opt_element
* @return {!Promise}
*/
mutateElement(mutator, opt_element) {
return this.element.getResources().mutateElement(
opt_element || this.element, mutator);
}
/**
* Schedules callback to be complete within the next batch. This call is
* intended for heavy DOM mutations that typically cause re-layouts.
* @param {!Function} callback
*/
deferMutate(callback) {
this.element.getResources().deferMutate(this.element, callback);
}
/**
* Collapses the element, setting it to `display: none`, and notifies its
* owner (if there is one) through {@link collapsedCallback} that the element
* is no longer visible.
*/
collapse() {
this.element.getResources().collapseElement(this.element);
}
/**
* Called every time an owned AmpElement collapses itself.
* See {@link collapse}.
* @param {!AmpElement} unusedElement
*/
collapsedCallback(unusedElement) {
// Subclasses may override.
}
/**
* Called when we just measured the layout rect of this element. Doing
* more expensive style reads should now be cheap.
* This may currently not work with extended elements. Please file
* an issue if that is required.
* @public
*/
onLayoutMeasure() {}
};
You can’t perform that action at this time.
