mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #2637 from Polymer/deepcontains
Add `Polymer.dom.deepContains`
This commit is contained in:
commit
f9d086b2f0
1946
src/lib/dom-api.html
1946
src/lib/dom-api.html
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@
|
||||
Polymer({
|
||||
is: 'x-test-no-distribute'
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<dom-module id="x-distribute">
|
||||
<template>
|
||||
@ -328,4 +328,24 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
</dom-module>
|
||||
|
||||
<dom-module id="x-deep-contains">
|
||||
<template>
|
||||
<div id="shadowed"></div>
|
||||
<content select="#light"></content>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-deep-contains',
|
||||
created: function() {
|
||||
var e = document.createElement('div');
|
||||
e.id = 'light';
|
||||
Polymer.dom(this).appendChild(e);
|
||||
e = document.createElement('div');
|
||||
e.id = 'notdistributed';
|
||||
Polymer.dom(this).appendChild(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
@ -53,6 +53,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<span>2</span>
|
||||
</div>
|
||||
|
||||
<x-deep-contains></x-deep-contains>
|
||||
|
||||
<script src="polymer-dom.js"></script>
|
||||
|
||||
</body>
|
||||
|
@ -53,6 +53,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<span>2</span>
|
||||
</div>
|
||||
|
||||
<x-deep-contains></x-deep-contains>
|
||||
|
||||
<script src="polymer-dom.js"></script>
|
||||
|
||||
</body>
|
||||
|
@ -632,7 +632,7 @@ suite('Polymer.dom', function() {
|
||||
} else {
|
||||
testHeight();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@ -917,4 +917,23 @@ suite('Polymer.dom non-distributed elements', function() {
|
||||
assert.equal(Polymer.dom(document.createElement('div')).getDestinationInsertionPoints().length, 0);
|
||||
assert.equal(Polymer.dom(document).getDestinationInsertionPoints().length, 0);
|
||||
});
|
||||
|
||||
test('Deep Contains', function() {
|
||||
var el = document.querySelector('x-deep-contains');
|
||||
var shadow = el.$.shadowed;
|
||||
var light = Polymer.dom(el).querySelector('#light');
|
||||
var notdistributed = Polymer.dom(el).children[1];
|
||||
var disconnected = document.createElement('div');
|
||||
var separate = document.createElement('div');
|
||||
document.body.appendChild(separate);
|
||||
|
||||
assert.equal(Polymer.dom(el).deepContains(el), true, 'Element should deepContain itself');
|
||||
assert.equal(Polymer.dom(el).deepContains(shadow), true, 'Shadowed Child element should be found');
|
||||
assert.equal(Polymer.dom(el).deepContains(light), true, 'Light Child element should be found');
|
||||
assert.equal(Polymer.dom(el).deepContains(notdistributed), true, 'Non-distributed child element should be found');
|
||||
assert.equal(Polymer.dom(el).deepContains(disconnected), false, 'Disconnected element should not be found');
|
||||
assert.equal(Polymer.dom(el).deepContains(separate), false, 'Unassociated, attached element should not be found');
|
||||
|
||||
document.body.removeChild(separate);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user