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

custom-style causing issues with @angular2-material library #64

Open
jaichandra opened this issue Aug 18, 2016 · 8 comments
Open

custom-style causing issues with @angular2-material library #64

jaichandra opened this issue Aug 18, 2016 · 8 comments

Comments

@jaichandra
Copy link

In apps which already use @angular2-material library, using polymer elements with angular2-polymer breaks material library css styles.

below line is causing issue:

PolymerDomAdapter.prototype.createStyleElement = function (css, doc) {
        if (doc === void 0) { doc = document; }
        var style = doc.createElement.call(doc, 'style', 'custom-style');
        this.appendChild(style, this.createTextNode(css));
        return style;
    };

Because the above code uses prototype and overrides the default createStyleElement function, it causes all styles to be converted to <style is="custom=style"> tags, thus breaking existing material library styles. Is there a work around for this?

@Saulis
Copy link
Contributor

Saulis commented Oct 3, 2016

Can't see any workarounds – this function should probably be refined a bit to create custom-style elements only when css has Polymer css mixins or properties present.

@Splaktar
Copy link
Contributor

Splaktar commented Nov 3, 2016

I have been seeing issues with material2 styles and it looks like this is the culprit. It's unfortunate that this is still sitting here unassigned :(

@Saulis Do you know how to detect if the css "has Polymer css mixins or properties present"? I'm guessing that this would need something more than just looking for @apply and CSS Variables? But wouldn't inspecting all of the contents of the style element come at a performance cost?

We've had to re-declare our material2 styles inside of Angular components to get them to work again. It's pretty ugly.

@Splaktar
Copy link
Contributor

Splaktar commented Nov 5, 2016

Actually, I debugged my issues further and with or without the is="custom-style" there was no change in behavior or Material2 styles. I found that I needed to configure Material2's new theming system for my app. After that, everything is working as expected with styling.

@jaichandra
Copy link
Author

@Splaktar can you share some details on how you configured material theming system to get it to work with polymer? Would be very helpful.

@logvi
Copy link

logvi commented Nov 10, 2016

The same issue for me. Can you please describe how to solve it?

@Splaktar
Copy link
Contributor

@jaichandra @logvi you can see the repo here and I have a blog post about upgrading from Angular 2 RC.4 and getting this working again here.

@logvi
Copy link

logvi commented Nov 14, 2016

@Splaktar Hm, it doesn't help me :(. I added custom theme but styles still overwritten by is="custom-style"

@Splaktar
Copy link
Contributor

@logvi the styles aren't overwritten, they just get the is="custom-style" attribute added to them. It doesn't break anything for me. What problem are you seeing exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants