Skip to content

Commit 9774c5a

Browse files
Add viewport width fix for legacy bundle (#1981)
* Add viewport width fix for legacy bundle * Explain the change more and disable it by default
1 parent 5f35ef7 commit 9774c5a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

injected/src/features/web-compat.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,23 @@ export class WebCompat extends ContentFeature {
141141
if (this.getFeatureSettingEnabled('enumerateDevices')) {
142142
this.deviceEnumerationFix();
143143
}
144+
// Used by Android in the non adsjs version
145+
// This has to be enabled in the config for the injectName='android' now.
146+
if (this.getFeatureSettingEnabled('viewportWidthLegacy', 'disabled')) {
147+
this.viewportWidthFix();
148+
}
144149
}
145150

146151
/**
147152
* Handle user preference updates when merged during initialization.
148153
* Re-applies viewport fixes if viewport configuration has changed.
154+
* Used in the injectName='android-adsjs' instead of 'viewportWidthLegacy' from init.
149155
* @param {object} _updatedConfig - The configuration with merged user preferences
150156
*/
151157
onUserPreferencesMerged(_updatedConfig) {
152158
// Re-apply viewport width fix if viewport settings might have changed
153159
if (this.getFeatureSettingEnabled('viewportWidth')) {
154-
if (!this._viewportWidthFixApplied) {
155-
this.viewportWidthFix();
156-
this._viewportWidthFixApplied = true;
157-
}
160+
this.viewportWidthFix();
158161
}
159162
}
160163

@@ -698,6 +701,10 @@ export class WebCompat extends ContentFeature {
698701
}
699702

700703
viewportWidthFix() {
704+
if (this._viewportWidthFixApplied) {
705+
return;
706+
}
707+
this._viewportWidthFixApplied = true;
701708
if (document.readyState === 'loading') {
702709
// if the document is not ready, we may miss the original viewport tag
703710
document.addEventListener('DOMContentLoaded', () => this.viewportWidthFixInner());

0 commit comments

Comments
 (0)