@webcomponents/custom-elements
Version:
HTML Custom Elements Polyfill
80 lines (73 loc) • 2.58 kB
HTML
<html>
<head>
<title>customElements#polyfillWrapFlushCallback</title>
<script>
(window.customElements = window.customElements || {}).forcePolyfill = true;
</script>
<script src="../../../../es6-promise/dist/es6-promise.auto.min.js"></script>
<script src="../../../../web-component-tester/browser.js"></script>
<script src="../../../custom-elements.min.js"></script>
</head>
<body>
<custom-element-0 id="elt_0_0">
<custom-element-1 id="elt_1_0">
<custom-element-2 id="elt_2_0"></custom-element-2>
<custom-element-0 id="elt_0_1">
</custom-element-0>
</custom-element-1>
<custom-element-2 id="elt_2_1">
<custom-element-2 id="elt_2_2"></custom-element-2>
</custom-element-2>
<custom-element-0 id="elt_0_2">
<custom-element-1 id="elt_1_1">
</custom-element-1>
<custom-element-2 id="elt_2_3"></custom-element-2>
</custom-element-0>
<custom-element-1 id="elt_1_2"></custom-element-1>
</custom-element-0>
<script>
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
test('When a flush callback is installed and multiple calls to define are ' +
'made calling the flush callback causes elements to upgrade in define-call ' +
'order and then document order.', function() {
let flush = undefined;
customElements.polyfillWrapFlushCallback(fn => {
flush = fn;
});
const upgradeLog = [];
class LogIDOnConstruct extends HTMLElement {
constructor() {
super();
upgradeLog.push(this.id);
}
}
customElements.define('custom-element-0', class extends LogIDOnConstruct {});
customElements.define('custom-element-1', class extends LogIDOnConstruct {});
customElements.define('custom-element-2', class extends LogIDOnConstruct {});
assert.deepEqual(upgradeLog, []);
flush();
assert.deepEqual(upgradeLog, [
"elt_0_0",
"elt_0_1",
"elt_0_2",
"elt_1_0",
"elt_1_1",
"elt_1_2",
"elt_2_0",
"elt_2_1",
"elt_2_2",
"elt_2_3",
]);
});
</script>
</body>
</html>