mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Expose a Document constructor instead. This also exposes that the TemplateBinding library might need more control over the registration context for custom elements. For now we make all documents share the same registration context. R=ojan@chromium.org, abarth@chromium.org Review URL: https://codereview.chromium.org/697363002
50 lines
1.7 KiB
Plaintext
50 lines
1.7 KiB
Plaintext
<html>
|
|
<import src="../resources/chai.sky" />
|
|
<import src="../resources/mocha.sky" />
|
|
<script>
|
|
describe('MutationObserver cross document moves', function() {
|
|
it('should handle basic observation', function(done) {
|
|
var mutations;
|
|
var div = document.createElement('div');
|
|
var observer = new MutationObserver(function(records) {
|
|
mutations = records;
|
|
});
|
|
|
|
observer.observe(div, {attributes: true});
|
|
var newDoc = new Document();
|
|
newDoc.appendChild(div);
|
|
div.id = 'foo';
|
|
setTimeout(function() {
|
|
assert.equal(mutations.length, 1);
|
|
assert.equal(mutations[0].type, 'attributes');
|
|
assert.equal(mutations[0].target, div);
|
|
assert.equal(mutations[0].attributeName, 'id');
|
|
observer.disconnect();
|
|
done();
|
|
}, 0);
|
|
});
|
|
it('should handle subtree observation', function(done) {
|
|
var mutations;
|
|
var div = document.createElement('div');
|
|
var subDiv = div.appendChild(document.createElement('div'));
|
|
var observer = new MutationObserver(function(records) {
|
|
mutations = records;
|
|
});
|
|
|
|
observer.observe(div, {attributes: true, subtree: true});
|
|
var newDoc = new Document();
|
|
newDoc.appendChild(div);
|
|
subDiv.id = 'foo';
|
|
setTimeout(function() {
|
|
assert.equal(mutations.length, 1);
|
|
assert.equal(mutations[0].type, 'attributes');
|
|
assert.equal(mutations[0].target, subDiv);
|
|
assert.equal(mutations[0].attributeName, 'id');
|
|
observer.disconnect();
|
|
done();
|
|
}, 0);
|
|
});
|
|
});
|
|
</script>
|
|
</html>
|