UNPKG

@webcomponents/custom-elements

Version:
45 lines (40 loc) 1.59 kB
<!doctype 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('Each installed flush callback wraps the previous callback.', function() { let calls = []; customElements.polyfillWrapFlushCallback(function callbackA(flush){ calls.push('callbackA'); flush(); }); customElements.polyfillWrapFlushCallback(function callbackB(flush){ calls.push('callbackB'); flush(); }); customElements.define('custom-element-1', class extends HTMLElement {}); assert.deepEqual(calls, ['callbackB', 'callbackA']); customElements.define('custom-element-2', class extends HTMLElement {}); assert.deepEqual(calls, ['callbackB', 'callbackA', 'callbackB', 'callbackA']); }); </script> </head> <body> </body> </html>