MCPcopy
hub / github.com/ampproject/amphtml / applyMediaAttrs_

Method applyMediaAttrs_

src/custom-element.js:1045–1082  ·  view source on GitHub ↗

@private

()

Source from the content-addressed store, hash-verified

1043
1044 /** @private */
1045 applyMediaAttrs_() {
1046 const props = this.mediaQueryProps_;
1047 if (!props) {
1048 return;
1049 }
1050
1051 props.start();
1052
1053 // Media query.
1054 const mediaAttr = this.getAttribute('media') || null;
1055 const matchesMedia = mediaAttr
1056 ? props.resolveMatchQuery(mediaAttr)
1057 : true;
1058 this.classList.toggle('i-amphtml-hidden-by-media-query', !matchesMedia);
1059
1060 // Sizes.
1061 const sizesAttr = this.hasAttribute('disable-inline-width')
1062 ? null
1063 : this.getAttribute('sizes');
1064 if (sizesAttr) {
1065 setStyle(this, 'width', props.resolveListQuery(sizesAttr));
1066 }
1067
1068 // Heights.
1069 const heightsAttr =
1070 this.layout_ === Layout_Enum.RESPONSIVE
1071 ? this.getAttribute('heights')
1072 : null;
1073 if (heightsAttr) {
1074 const sizer = this.getSizer_();
1075 if (sizer) {
1076 setStyle(sizer, 'paddingTop', props.resolveListQuery(heightsAttr));
1077 }
1078 }
1079
1080 props.complete();
1081 this.getResource_().requestMeasure();
1082 }
1083
1084 /**
1085 * Applies a size change to the element.

Callers 1

initMediaAttrs_Method · 0.95

Calls 10

getSizer_Method · 0.95
getResource_Method · 0.95
setStyleFunction · 0.90
getAttributeMethod · 0.80
resolveMatchQueryMethod · 0.80
resolveListQueryMethod · 0.80
requestMeasureMethod · 0.80
startMethod · 0.45
toggleMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected