OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function watchForTag(tagName, cb) { | 5 function watchForTag(tagName, cb) { |
6 if (!document.body) | 6 if (!document.body) |
7 return; | 7 return; |
8 | 8 |
9 function findChildTags(queryNode) { | 9 function findChildTags(queryNode) { |
10 $Array.forEach(queryNode.querySelectorAll(tagName), function(node) { | 10 $Array.forEach(queryNode.querySelectorAll(tagName), function(node) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 var useCapture = true; | 45 var useCapture = true; |
46 window.addEventListener('readystatechange', function listener(event) { | 46 window.addEventListener('readystatechange', function listener(event) { |
47 if (document.readyState == 'loading') | 47 if (document.readyState == 'loading') |
48 return; | 48 return; |
49 | 49 |
50 watchForTag(tagName, cb); | 50 watchForTag(tagName, cb); |
51 window.removeEventListener(event.type, listener, useCapture); | 51 window.removeEventListener(event.type, listener, useCapture); |
52 }, useCapture); | 52 }, useCapture); |
53 } | 53 } |
54 | 54 |
55 exports.addTagWatcher = addTagWatcher; | 55 exports.$set('addTagWatcher', addTagWatcher); |
OLD | NEW |