Skip to content

Commit

Permalink
[apply shim] Track dependencies for mixins before creation
Browse files Browse the repository at this point in the history
Fixes #3802 (again)
  • Loading branch information
dfreedm committed Jul 27, 2016
1 parent d02aecd commit 2cab461
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/apply-shim.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@

function mapGet(name) {
name = name.trim();
return mixinMap[name];
var entry = mixinMap[name];
// if the mixin is not defined, make an entry so we can set up dependencies correctly
if (!entry) {
mapSet(name, {});
entry = mixinMap[name];
}
return entry;
}

// "parse" a mixin definition into a map of properties and values
Expand Down
46 changes: 46 additions & 0 deletions test/unit/styling-cross-scope-apply.html
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,43 @@
}
</style>

<dom-module id="x-apply-depend-before-create">
<template>
<style>
:host {
@apply --before-create;
}
</style>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-apply-depend-before-create'
})
})
</script>
</dom-module>

<dom-module id="x-create-after-apply">
<template>
<style>
:host {
--before-create: {
border: 2px solid green;
}
}
</style>
<x-apply-depend-before-create id="child"></x-apply-depend-before-create>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-create-after-apply'
})
})
</script>
</dom-module>

<script>
suite('scoped-styling-apply', function() {
function assertComputed(element, value, property) {
Expand Down Expand Up @@ -736,6 +773,15 @@
assert.equal(parent2Text, parent3Text, 'x-produce-mixin-3 should not have invalidated x-consume-mixin');
}
});

test('mixins can be depended on before creation', function() {
var e = document.createElement('x-apply-depend-before-create');
document.body.appendChild(e);
var e2 = document.createElement('x-create-after-apply');
document.body.appendChild(e2);
CustomElements.takeRecords();
assertComputed(e2.$.child, '2px');
});
});

</script>
Expand Down

0 comments on commit 2cab461

Please sign in to comment.