Skip to content

Commit 73fa567

Browse files
committed
Add preferred alternatives to problematic terminology, closes #30789
- Add computeInCoordinatingFrame as alias for computeInMasterFrame - Add coordinator property as alias for master - Add isCoordinator property as alias for isMaster - Update documentation to reference preferred alternatives - Maintain backward compatibility with existing APIs
1 parent 593e099 commit 73fa567

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

3p/3p.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ export function computeInMasterFrame(global, taskId, work, cb) {
195195
});
196196
}
197197

198+
/**
199+
* Preferred alternative to computeInMasterFrame.
200+
* @param {!Window} global
201+
* @param {string} taskId
202+
* @param {function(*)} work
203+
* @param {function(*)} cb
204+
* @return {undefined}
205+
*/
206+
export function computeInCoordinatingFrame(global, taskId, work, cb) {
207+
return computeInMasterFrame(global, taskId, work, cb);
208+
}
209+
198210
/**
199211
* Validates given data. Throws an exception if the data does not
200212
* contains a mandatory field. If called with the optional param

3p/ampcontext-integration.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {dev, user, userAssert} from '#utils/log';
22

3-
import {computeInMasterFrame} from './3p';
3+
import {computeInCoordinatingFrame, computeInMasterFrame} from './3p';
44
import {AbstractAmpContext} from './ampcontext';
55

66
/**
@@ -67,6 +67,11 @@ export class IntegrationAmpContext extends AbstractAmpContext {
6767
return masterSelection(this.win_, dev().assertString(this.embedType_));
6868
}
6969

70+
/** @return {!Window} */
71+
get coordinator() {
72+
return this.master_();
73+
}
74+
7075
/** @return {boolean} */
7176
get isMaster() {
7277
return this.isMaster_();
@@ -77,6 +82,11 @@ export class IntegrationAmpContext extends AbstractAmpContext {
7782
return this.master == this.win_;
7883
}
7984

85+
/** @return {boolean} */
86+
get isCoordinator() {
87+
return this.isMaster_();
88+
}
89+
8090
/**
8191
* @param {number} width
8292
* @param {number} height
@@ -133,4 +143,15 @@ export class IntegrationAmpContext extends AbstractAmpContext {
133143
computeInMasterFrame(global, taskId, work, cb) {
134144
computeInMasterFrame(global, taskId, work, cb);
135145
}
146+
147+
/**
148+
* Preferred alternative to computeInMasterFrame.
149+
* @param {!Window} global
150+
* @param {string} taskId
151+
* @param {function(*)} work
152+
* @param {function(*)} cb
153+
*/
154+
computeInCoordinatingFrame(global, taskId, work, cb) {
155+
computeInCoordinatingFrame(global, taskId, work, cb);
156+
}
136157
}

ads/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,12 @@ documentation with the new behaviors on user's consent choices. You can refer to
281281

282282
To allow ads to bundle HTTP requests across multiple ad units on the same page the object `window.context.master` will contain the window object of the iframe being elected master iframe for the current page. The `window.context.isMaster` property is `true` when the current frame is the master frame.
283283

284+
**Note:** Preferred alternatives are available as `window.context.coordinator` and `window.context.isCoordinator` respectively.
285+
284286
The `computeInMasterFrame` function is designed to make it easy to perform a task only in the master frame and provide the result to all frames. It is also available to custom ad iframes as `window.context.computeInMasterFrame`. See [3p.js](https://github.com/ampproject/amphtml/blob/main/3p/3p.js) for function signature.
285287

288+
**Note:** A preferred alternative is available as `window.context.computeInCoordinatingFrame`.
289+
286290
#### Preconnect and prefetch
287291

288292
Add the JS URLs that an ad **always** fetches or always connects to (if you know the origin but not the path) to [\_config.js](_config.js).

build-system/externs/amp.extern.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ window.context.sourceUrl;
187187
window.context.experimentToggles;
188188
window.context.master;
189189
window.context.isMaster;
190+
window.context.coordinator;
191+
window.context.isCoordinator;
190192
window.context.ampcontextVersion;
191193
window.context.ampcontextFilepath;
192194
window.context.canary;

0 commit comments

Comments
 (0)