|
| 1 | +<!DOCTYPE html> |
| 2 | +<!-- |
| 3 | +@license |
| 4 | +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 | +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
| 6 | +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 | +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
| 8 | +Code distributed by Google as part of the polymer project is also |
| 9 | +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
| 10 | +--> |
| 11 | +<!DOCTYPE html> |
| 12 | +<html> |
| 13 | + <head> |
| 14 | + <meta charset="utf-8"> |
| 15 | + <script src="../../../webcomponentsjs/webcomponents-lite.js"></script> |
| 16 | + <script> |
| 17 | + window.WCT = { |
| 18 | + // don't wait for HTML Imports to load |
| 19 | + waitFor: function(cb) { |
| 20 | + cb(); |
| 21 | + } |
| 22 | + }; |
| 23 | + </script> |
| 24 | + <script src="../../../web-component-tester/browser.js"></script> |
| 25 | + <link rel="import" href="../../polymer.html"> |
| 26 | + <script> |
| 27 | + Polymer({ |
| 28 | + is: 'attach-detach', |
| 29 | + properties: { |
| 30 | + stream: { |
| 31 | + type: Array, |
| 32 | + value: function(){ return []; } |
| 33 | + } |
| 34 | + }, |
| 35 | + attached: function() { |
| 36 | + this.stream.push('attached'); |
| 37 | + }, |
| 38 | + detached: function() { |
| 39 | + this.stream.push('detached'); |
| 40 | + } |
| 41 | + }); |
| 42 | + </script> |
| 43 | + <script> |
| 44 | + function checkOrder(el) { |
| 45 | + assert.equal(el.stream.join(' '), [ |
| 46 | + 'attached', |
| 47 | + 'detached' |
| 48 | + ].join(' ')); |
| 49 | + } |
| 50 | + </script> |
| 51 | + </head> |
| 52 | + <body> |
| 53 | + <attach-detach id="ad"></attach-detach> |
| 54 | + <script> |
| 55 | + var ad = document.getElementById('ad'); |
| 56 | + ad.remove(); |
| 57 | + var el = document.createElement('attach-detach'); |
| 58 | + document.body.appendChild(el); |
| 59 | + el.remove(); |
| 60 | + test('attach() and detach() are correct for upgraded elements', function() { |
| 61 | + checkOrder(ad); |
| 62 | + }); |
| 63 | + test('attach() and detach() are correct for imperative elements', function() { |
| 64 | + checkOrder(el); |
| 65 | + }); |
| 66 | + test('attach() and detach() are correct for elements made after load', function() { |
| 67 | + var e = document.createElement('attach-detach'); |
| 68 | + document.body.appendChild(e); |
| 69 | + e.remove(); |
| 70 | + checkOrder(e); |
| 71 | + }); |
| 72 | + </script> |
| 73 | + </body> |
| 74 | +</html> |
0 commit comments