Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Allow adding type="custom" to avoid deprecation warning. Fixes #5017 #5019

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this unconditional to support type="custom" in the main page. Less footgunny.

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() {
var 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