Skip to content

Commit

Permalink
Merge branch 'master' into querySelectorAll
Browse files Browse the repository at this point in the history
  • Loading branch information
Micajuine Ho committed Mar 31, 2020
2 parents 97c92a9 + 720f670 commit c4b9cc5
Show file tree
Hide file tree
Showing 1,584 changed files with 25,551 additions and 17,028 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test/coverage/**
# Code directories
build-system/tasks/visual-diff/snippets/*.js
build-system/babel-plugins/**/fixtures/**/*.js
build-system/babel-plugins/**/fixtures/**/*.mjs
build-system/server/app-index/test/*.js
examples/**
extensions/amp-a4a/0.1/test/testdata/**
Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
🐛 Bug fix
🔥 P0 fix
✅ Tests
❄️ Flaky tests
🚀 Performance improvements
🖍 CSS / Styling
♿ Accessibility
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ firebase
firebase.json
.firebase/
src/purifier/dist
build-system/server/new-server/transforms/dist
build-system/tasks/performance/cache
build-system/tasks/performance/results.json
12 changes: 8 additions & 4 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# 6. If using the Local AMP Chrome Extension, open the popup and configure the Base URL to be https://amphtml.lando.site/
#
# Now instead of running `gulp` commands directly, you instead run `lando gulp`. Additionally, some of the common gulp
# commands have shortcuts, so you can run `lando watch` instead of `lando gulp watch`. For a full list of the shortcuts
# run `lando help`.
# commands have shortcuts, so you can run `lando watch` instead of `lando gulp build --watch`. For a full list of the
# shortcuts run `lando help`.
#
# For details on the file format, see <https://docs.lando.dev/config/lando.html>.
# For more context on this Lando environment for amphtml, see <https://github.com/ampproject/amphtml/pull/23213>.
Expand Down Expand Up @@ -46,8 +46,12 @@ tooling:
cmd: 'yarn gulp'
watch:
service: appserver
cmd: 'yarn gulp watch'
description: 'Watches for changes in files, re-builds when detected'
cmd: 'yarn gulp build --watch'
description: 'Builds unminified code, watches for changes in files, re-builds when detected'
watch-minified:
service: appserver
cmd: 'yarn gulp dist --watch'
description: 'Builds minified code, watches for changes in files, re-builds when detected'
lint:
service: appserver
cmd: 'yarn gulp lint'
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ branches:
- master
- release
- canary
- nightly
- /^amp-release-.*$/
addons:
apt:
Expand Down
14 changes: 7 additions & 7 deletions 3p/3d-gltf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {user} from '../../src/log';

import GltfViewer from './viewer';

const seq = (taskA, taskB) => cb => taskA(() => taskB(cb));
const parallel = (taskA, taskB) => cb => {
const seq = (taskA, taskB) => (cb) => taskA(() => taskB(cb));
const parallel = (taskA, taskB) => (cb) => {
let n = 0;
const finish = () => {
n++;
Expand All @@ -36,8 +36,8 @@ const parallel = (taskA, taskB) => cb => {
};

const loadThree = (global, cb) => {
const loadScriptCb = url => cb => loadScript(global, url, cb);
const loadThreeExample = examplePath =>
const loadScriptCb = (url) => (cb) => loadScript(global, url, cb);
const loadThreeExample = (examplePath) =>
loadScriptCb(
'https://cdn.jsdelivr.net/npm/three@0.91/examples/js/' + examplePath
);
Expand All @@ -62,7 +62,7 @@ export function gltfViewer(global) {
onload: () => {
nonSensitiveDataPostMessage('loaded');
},
onprogress: e => {
onprogress: (e) => {
if (!e.lengthComputable) {
return;
}
Expand All @@ -74,7 +74,7 @@ export function gltfViewer(global) {
})
);
},
onerror: err => {
onerror: (err) => {
user().error('3DGLTF', err);
nonSensitiveDataPostMessage(
'error',
Expand All @@ -84,7 +84,7 @@ export function gltfViewer(global) {
);
},
});
listenParent(global, 'action', msg => {
listenParent(global, 'action', (msg) => {
viewer.actions[msg['action']](msg['args']);
});
nonSensitiveDataPostMessage('ready');
Expand Down
6 changes: 3 additions & 3 deletions 3p/3d-gltf/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class GltfViewer {
let oldW = null;
let oldH = null;
/** @param {JsonObject} box */
const setSize = box => {
const setSize = (box) => {
const w = box['width'];
const h = box['height'];
if (oldW === w && oldH === h) {
Expand Down Expand Up @@ -250,9 +250,9 @@ export default class GltfViewer {
loader.load(
this.options_['src'],
/** @param {{scene: !THREE.Scene}} gltfData */
gltfData => {
(gltfData) => {
this.setupCameraForObject_(gltfData.scene);
gltfData.scene.children.slice().forEach(child => {
gltfData.scene.children.slice().forEach((child) => {
this.model_.add(child);
});

Expand Down
4 changes: 2 additions & 2 deletions 3p/3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function computeInMasterFrame(global, taskId, work, cb) {
if (!global.context.isMaster) {
return; // Only do work in master.
}
work(result => {
work((result) => {
for (let i = 0; i < cbs.length; i++) {
cbs[i].call(null, result);
}
Expand Down Expand Up @@ -254,7 +254,7 @@ export function validateData(data, mandatoryFields, opt_optionalFields) {
*/
function validateExactlyOne(data, alternativeFields) {
userAssert(
alternativeFields.filter(field => data[field]).length === 1,
alternativeFields.filter((field) => data[field]).length === 1,
'%s must contain exactly one of attributes: %s.',
data.type,
alternativeFields.join(', ')
Expand Down
10 changes: 5 additions & 5 deletions 3p/ampcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class AbstractAmpContext {
this.client_.makeRequest(
MessageType.SEND_EMBED_STATE,
MessageType.EMBED_STATE,
data => {
(data) => {
this.hidden = data['pageHidden'];
this.dispatchVisibilityChangeEvent_();
}
Expand All @@ -155,7 +155,7 @@ export class AbstractAmpContext {
* every time we receive a page visibility message.
*/
onPageVisibilityChange(callback) {
return this.client_.registerCallback(MessageType.EMBED_STATE, data => {
return this.client_.registerCallback(MessageType.EMBED_STATE, (data) => {
callback({hidden: data['pageHidden']});
});
}
Expand All @@ -171,7 +171,7 @@ export class AbstractAmpContext {
return this.client_.makeRequest(
MessageType.SEND_INTERSECTIONS,
MessageType.INTERSECTION,
intersection => {
(intersection) => {
callback(intersection['changes']);
}
);
Expand Down Expand Up @@ -230,7 +230,7 @@ export class AbstractAmpContext {
* request succeeds.
*/
onResizeSuccess(callback) {
this.client_.registerCallback(MessageType.EMBED_SIZE_CHANGED, obj => {
this.client_.registerCallback(MessageType.EMBED_SIZE_CHANGED, (obj) => {
callback(obj['requestedHeight'], obj['requestedWidth']);
});
}
Expand All @@ -243,7 +243,7 @@ export class AbstractAmpContext {
* request is denied.
*/
onResizeDenied(callback) {
this.client_.registerCallback(MessageType.EMBED_SIZE_DENIED, obj => {
this.client_.registerCallback(MessageType.EMBED_SIZE_DENIED, (obj) => {
callback(obj['requestedHeight'], obj['requestedWidth']);
});
}
Expand Down
10 changes: 5 additions & 5 deletions 3p/beopinion.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {setStyles} from '../src/style';
* @param {!Window} global
*/
function getBeOpinion(global) {
loadScript(global, 'https://widget.beopinion.com/sdk.js', function() {});
loadScript(global, 'https://widget.beopinion.com/sdk.js', function () {});
}

/**
Expand Down Expand Up @@ -87,20 +87,20 @@ function createContainer(global, data) {
*/
function getBeOpinionAsyncInit(global, accountId) {
const {context} = global;
return function() {
context.onResizeDenied(function(requestedHeight, requestedWidth) {
return function () {
context.onResizeDenied(function (requestedHeight, requestedWidth) {
context.requestResize(requestedWidth, requestedHeight);
});
global.BeOpinionSDK.init({
account: accountId,
onContentReceive: function(hasContent) {
onContentReceive: function (hasContent) {
if (hasContent) {
context.renderStart();
} else {
context.noContentAvailable();
}
},
onHeightChange: function(newHeight) {
onHeightChange: function (newHeight) {
const c = global.document.getElementById('c');
const boundingClientRect = c./*REVIEW*/ getBoundingClientRect();
context.requestResize(boundingClientRect.width, newHeight);
Expand Down
4 changes: 2 additions & 2 deletions 3p/bodymovinanimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getBodymovinAnimationSdk(global, renderer, cb) {
renderer === 'svg'
? 'https://cdnjs.cloudflare.com/ajax/libs/bodymovin/4.13.0/bodymovin_light.min.js'
: 'https://cdnjs.cloudflare.com/ajax/libs/bodymovin/4.13.0/bodymovin.min.js';
loadScript(global, scriptToLoad, function() {
loadScript(global, scriptToLoad, function () {
cb(global.bodymovin);
});
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export function bodymovinanimation(global) {
const shouldLoop = dataLoop != 'false';
const loop = !isNaN(dataLoop) ? dataLoop : shouldLoop;
const renderer = dataReceived['renderer'];
getBodymovinAnimationSdk(global, renderer, function(bodymovin) {
getBodymovinAnimationSdk(global, renderer, function (bodymovin) {
animationHandler = bodymovin.loadAnimation({
container: animatingContainer,
renderer,
Expand Down
6 changes: 3 additions & 3 deletions 3p/embedly.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const CardOptions = {
* @visibleForTesting
*/
function getEmbedly(global, callback) {
loadScript(global, EMBEDLY_SDK_URL, function() {
loadScript(global, EMBEDLY_SDK_URL, function () {
callback();
});
}
Expand Down Expand Up @@ -98,15 +98,15 @@ export function embedly(global, data) {

container.appendChild(card);

getEmbedly(global, function() {
getEmbedly(global, function () {
// Given by the parent frame.
delete data.width;
delete data.height;

global.window['embedly']('card', card);

// Use embedly SDK to listen to resize event from loaded card
global.window['embedly']('on', RESIZE_EVENT_NAME, function(iframe) {
global.window['embedly']('on', RESIZE_EVENT_NAME, function (iframe) {
context.requestResize(
iframe./*OK*/ width,
parseInt(iframe./*OK*/ height, 10) + /* margin */ 5
Expand Down
25 changes: 13 additions & 12 deletions 3p/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function setInViewportForTesting(inV) {
// Active intervals. Must be global, because people clear intervals
// with clearInterval from a different window.
const intervals = {};
let intervalId = 0;
let intervalId = 1;

/**
* Add instrumentation to a window and all child iframes.
Expand Down Expand Up @@ -73,8 +73,8 @@ function manageWin_(win) {
function instrumentDocWrite(parent, win) {
const doc = win.document;
const {close} = doc;
doc.close = function() {
parent.ampManageWin = function(win) {
doc.close = function () {
parent.ampManageWin = function (win) {
manageWin(win);
};
if (!parent.ampSeen) {
Expand All @@ -93,7 +93,7 @@ function instrumentDocWrite(parent, win) {
*/
function instrumentSrcdoc(parent, iframe) {
let srcdoc = iframe.getAttribute('srcdoc');
parent.ampManageWin = function(win) {
parent.ampManageWin = function (win) {
manageWin(win);
};
srcdoc += '<script>window.parent.ampManageWin(window)</script>';
Expand Down Expand Up @@ -159,7 +159,7 @@ function installObserver(win) {
if (!window.MutationObserver) {
return;
}
const observer = new MutationObserver(function(mutations) {
const observer = new MutationObserver(function (mutations) {
for (let i = 0; i < mutations.length; i++) {
maybeInstrumentsNodes(win, mutations[i].addedNodes);
}
Expand All @@ -177,14 +177,14 @@ function installObserver(win) {
function instrumentEntryPoints(win) {
// Change setTimeout to respect a minimum timeout.
const {setTimeout} = win;
win.setTimeout = function(fn, time) {
win.setTimeout = function (fn, time) {
time = minTime(time);
arguments[1] = time;
return setTimeout.apply(this, arguments);
};
// Implement setInterval in terms of setTimeout to make
// it respect the same rules
win.setInterval = function(fn) {
win.setInterval = function (fn) {
const id = intervalId++;
const args = Array.prototype.slice.call(arguments);
/**
Expand All @@ -195,7 +195,8 @@ function instrumentEntryPoints(win) {
next();
if (typeof fn == 'string') {
// Handle rare and dangerous string arg case.
return (0, win.eval /*NOT OK but whatcha gonna do.*/).call(win, fn); // lgtm [js/useless-expression]
return (0, win.eval) /*NOT OK but whatcha gonna do.*/
.call(win, fn); // lgtm [js/useless-expression]
} else {
return fn.apply(this, arguments);
}
Expand All @@ -211,7 +212,7 @@ function instrumentEntryPoints(win) {
return id;
};
const {clearInterval} = win;
win.clearInterval = function(id) {
win.clearInterval = function (id) {
clearInterval(id);
win.clearTimeout(intervals[id]);
delete intervals[id];
Expand All @@ -235,11 +236,11 @@ function blockSyncPopups(win) {
}
try {
win.alert = maybeThrow;
win.prompt = function() {
win.prompt = function () {
maybeThrow();
return '';
};
win.confirm = function() {
win.confirm = function () {
maybeThrow();
return false;
};
Expand Down Expand Up @@ -269,7 +270,7 @@ function minTime(time) {
* Installs embed state listener.
*/
export function installEmbedStateListener() {
listenParent(window, 'embed-state', function(data) {
listenParent(window, 'embed-state', function (data) {
inViewport = data['inViewport'];
});
}
4 changes: 2 additions & 2 deletions 3p/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ export function facebook(global, data) {

getFacebookSdk(
global,
FB => {
(FB) => {
// Dimensions are given by the parent frame.
delete data.width;
delete data.height;

FB.Event.subscribe('xfbml.resize', event => {
FB.Event.subscribe('xfbml.resize', (event) => {
context.updateDimensions(
parseInt(event.width, 10),
parseInt(event.height, 10) + /* margins */ 20
Expand Down
4 changes: 2 additions & 2 deletions 3p/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {writeScript} from './3p';
* @param {function()} cb
*/
function getGistJs(global, scriptSource, cb) {
writeScript(global, scriptSource, function() {
writeScript(global, scriptSource, function () {
cb();
});
}
Expand All @@ -52,7 +52,7 @@ export function github(global, data) {
gistUrl += '?file=' + encodeURIComponent(data.file);
}

getGistJs(global, gistUrl, function() {
getGistJs(global, gistUrl, function () {
// Dimensions are given by the parent frame.
delete data.width;
delete data.height;
Expand Down
Loading

0 comments on commit c4b9cc5

Please sign in to comment.