@webcomponents/custom-elements
Version:
HTML Custom Elements Polyfill
44 lines (42 loc) • 1.77 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>
<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, ' +
'the flush callback is called only once during the first call to define.', function() {
let flush = undefined;
let flushCallbackCallCount = 0;
customElements.polyfillWrapFlushCallback(fn => {
flushCallbackCallCount++;
flush = fn;
});
customElements.define('custom-element-1', class extends HTMLElement {});
customElements.define('custom-element-2', class extends HTMLElement {});
assert(flushCallbackCallCount === 1);
flush();
customElements.define('custom-element-3', class extends HTMLElement {});
customElements.define('custom-element-4', class extends HTMLElement {});
customElements.define('custom-element-5', class extends HTMLElement {});
assert(flushCallbackCallCount === 2);
});
</script>
</head>
<body>
</body>
</html>