Skip to content

Commit

Permalink
Allow adding type="custom" to avoid deprecation warning. Fixes #5017
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jan 5, 2018
1 parent 7b6ff53 commit 8ae3955
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@
cases of ordering w.r.t the main document styles.
*/
if (this.ownerDocument !== window.document && this.__appliedElement === this) {
// Allow users to add `type="custom"` to <style> tags to avoid deprecation warning
var type = this.getAttribute('type');
if (type == 'custom') {
this.removeAttribute('type');
}
document.head.appendChild(this);
}
// needed becuase elements in imports do not get 'attached'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom-style-import.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<link rel="import" href="sub/style-import.html">

<style is="custom-style" include="shared-style style-import
style-import2">
style-import2" type="custom" id="type-was-custom">
:root {

--import-mixin: {
Expand Down
5 changes: 5 additions & 0 deletions test/unit/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@
assertComputed(m, '4px');
});

test('imported custom-style style with type="custom" has type removed', function() {
const style = document.head.querySelector('style#type-was-custom');
assert.isFalse(style.hasAttribute('type'));
});

test('dynamic custom-styles apply', function() {
var dynamic = document.querySelector('.dynamic');
assertComputed(dynamic, '0px');
Expand Down

0 comments on commit 8ae3955

Please sign in to comment.