AMP ⚡
AMP
PWA

AMP Playground
https://playground.amp.dev/?runtime=amp4email
<!doctype html>
<html 4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp4email-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
h1 {
margin: 1rem;
}
</style>
</head>
<body>
<h1>Hello, I am an AMP EMAIL!</h1>
</body>
</html>
custom-element

<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<title>Hello, AMPs</title>
<link rel="canonical" href="https://amp.dev/zh_cn/documentation/guides-and-tutorials/start/create/basic_markup/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"headline": "Open-source framework for publishing content",
"datePublished": "2015-10-07T12:02:41Z",
"image": [
"logo.jpg"
]
}
</script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<h1>Welcome to the mobile web</h1>
</body>
</html>
Chrome Devtools
https://developers.google.com/web/updates/2020/03/devtools
Grid Layout

/**
* Copyright 2017 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 {ElementStub, stubbedElements} from '../element-stub';
import {createCustomElementClass} from '../custom-element';
import {extensionScriptsInNode} from '../element-service';
import {reportError} from '../error';
import {userAssert} from '../log';
/**
* @param {!Window} win
* @return {!Object<string, typeof ../base-element.BaseElement>}
*/
function getExtendedElements(win) {
if (!win.__AMP_EXTENDED_ELEMENTS) {
win.__AMP_EXTENDED_ELEMENTS = {};
}
return win.__AMP_EXTENDED_ELEMENTS;
}
/**
* Registers an element. Upgrades it if has previously been stubbed.
* @param {!Window} win
* @param {string} name
* @param {typeof ../base-element.BaseElement} toClass
*/
export function upgradeOrRegisterElement(win, name, toClass) {
const knownElements = getExtendedElements(win);
if (!knownElements[name]) {
registerElement(win, name, toClass);
return;
}
if (knownElements[name] == toClass) {
// Already registered this instance.
return;
}
userAssert(
knownElements[name] == ElementStub,
'%s is already registered. The script tag for ' +
'%s is likely included twice in the page.',
name,
name
);
knownElements[name] = toClass;
for (let i = 0; i < stubbedElements.length; i++) {
const stub = stubbedElements[i];
// There are 3 possible states here:
// 1. We never made the stub because the extended impl. loaded first.
// In that case the element won't be in the array.
// 2. We made a stub but the browser didn't attach it yet. In
// that case we don't need to upgrade but simply switch to the new
// implementation.
// 3. A stub was attached. We upgrade which means we replay the
// implementation.
const {element} = stub;
if (
element.tagName.toLowerCase() == name &&
element.ownerDocument.defaultView == win
) {
tryUpgradeElement_(element, toClass);
// Remove element from array.
stubbedElements.splice(i--, 1);
}
}
}
/**
* This method should not be inlined to prevent TryCatch deoptimization.
* @param {Element} element
* @param {typeof ../base-element.BaseElement} toClass
* @private
* @noinline
*/
function tryUpgradeElement_(element, toClass) {
try {
element.upgrade(toClass);
} catch (e) {
reportError(e, element);
}
}
/**
* Stub extended elements missing an implementation. It can be called multiple
* times and on partial document in order to start stubbing as early as
* possible.
* @param {!./ampdoc-impl.AmpDoc} ampdoc
*/
export function stubElementsForDoc(ampdoc) {
const extensions = extensionScriptsInNode(ampdoc.getHeadNode());
extensions.forEach((name) => {
ampdoc.declareExtension(name);
stubElementIfNotKnown(ampdoc.win, name);
});
}
/**
* Stub element if not yet known.
* @param {!Window} win
* @param {string} name
*/
export function stubElementIfNotKnown(win, name) {
const knownElements = getExtendedElements(win);
if (!knownElements[name]) {
registerElement(win, name, ElementStub);
}
}
/**
* Copies the specified element to child window (friendly iframe). This way
* all implementations of the AMP elements are shared between all friendly
* frames.
* @param {!Window} parentWin
* @param {!Window} childWin
* @param {string} name
*/
export function copyElementToChildWindow(parentWin, childWin, name) {
const toClass = getExtendedElements(parentWin)[name];
registerElement(childWin, name, toClass || ElementStub);
}
/**
* Registers a new custom element with its implementation class.
* @param {!Window} win The window in which to register the elements.
* @param {string} name Name of the custom element
* @param {typeof ../base-element.BaseElement} implementationClass
*/
export function registerElement(win, name, implementationClass) {
const knownElements = getExtendedElements(win);
knownElements[name] = implementationClass;
const klass = createCustomElementClass(win);
win['customElements'].define(name, klass);
}
/**
* In order to provide better error messages we only allow to retrieve
* services from other elements if those elements are loaded in the page.
* This makes it possible to mark an element as loaded in a test.
* @param {!Window} win
* @param {string} elementName Name of an extended custom element.
* @visibleForTesting
*/
export function markElementScheduledForTesting(win, elementName) {
const knownElements = getExtendedElements(win);
if (!knownElements[elementName]) {
knownElements[elementName] = ElementStub;
}
}
/**
* Resets our scheduled elements.
* @param {!Window} win
* @param {string} elementName Name of an extended custom element.
* @visibleForTesting
*/
export function resetScheduledElementForTesting(win, elementName) {
if (win.__AMP_EXTENDED_ELEMENTS) {
delete win.__AMP_EXTENDED_ELEMENTS[elementName];
}
}
/**
* Returns a currently registered element class.
* @param {!Window} win
* @param {string} elementName Name of an extended custom element.
* @return {?function()}
* @visibleForTesting
*/
export function getElementClassForTesting(win, elementName) {
const knownElements = win.__AMP_EXTENDED_ELEMENTS;
return (knownElements && knownElements[elementName]) || null;
}
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
随机推荐
- Zookeeper C API的学习 以及样例 很赞
https://www.cnblogs.com/haippy/archive/2013/02/21/2920280.html
- 【LinuxShell】free 命令详解
前言 free命令用来显示Linux中的内存使用信息,包括空闲的.已用的物理内存,swap内存,及被内核使用的buffer.在Linux系统监控的工具中,free命令是最经常使用的命令之一. 命令格式 ...
- LibreOJ #10047
应同机房某大佬的要求来写这篇题解 Description 给定一个字符串 \(S\) 和一个数 \(K\),要求求出 \(S\) 的所有形似 \(A+B+A\) 的子串数量,其中 \(\mid A\m ...
- 希尔伯特曲线python3实现
需要OpenGL库:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl #coding:utf-8 from OpenGL.GL import * ...
- 使用Docker Registry管理Docker镜像
文章目录 使用Docker Registry管理Docker镜像 1.使用Docker Hub管理镜像 1.1注册与登录 1.2创建仓库 1.3推送镜像 2. 使用私有仓库管理镜像 2.1 搭建私有仓 ...
- Java 复习整理day08
package com.it.demo02_lambda; //接口, 表示动物. //public abstract class Animal { //报错, Lambda表达式只针对于接口有效 p ...
- 如何安装Python 3.9.1?
首先打开浏览器输入网址:https://www.python.org或者通过百度搜索python进入Python官网. 选择Downloads,弹出最新版本下载链接,当前版本为3.9.1,如图所示: ...
- A - 规律题
我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目.比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示. Input输 ...
- Codeforces Round #585 (Div. 2) E. Marbles(状压dp)
题意:给你一个长度为n的序列 问你需要多少次两两交换 可以让相同的数字在一个区间段 思路:我们可以预处理一个数组cnt[i][j]表示把i放到j前面需要交换多少次 然后二进制枚举后 每次选择一个为1的 ...
- 2288.【POJ Challenge】生日礼物 链表+堆+贪心
BZOJ2288 [POJ Challenge]生日礼物 题意: 给一个长度为\(n\)的数组,最多可以选\(m\)个连续段,问选取的最大值是多少 题解: 先把连续的符号相同的值合并,头和尾的负数去掉 ...