-
Notifications
You must be signed in to change notification settings - Fork 34
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
PolymerDomSharedStylesHost breaks Polymer components on non-Chrome browsers #33
Comments
Thank you for the detailed post! I'm having trouble recreating this though. What raises a red flag for me is this that you mention you see this in Firefox: <custom-style>
<style scope="app-drawer" is="custom-style">
...
This sounds more like something the old Let's do a quick sanity check. Can you go into your
I'm running on:
Also go through your app and see if you're making any calls to These are my files: index.html <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Origami Demo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="assets/bower_components/webcomponentsjs/webcomponents-loader.js"></script>
<link href="assets/bower_components/app-layout/app-drawer/app-drawer.html" rel="import">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html> src/main.ts import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { webcomponentsReady } from '@codebakery/origami';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
webcomponentsReady().then(() => {
platformBrowserDynamic().bootstrapModule(AppModule);
}).catch(error => {
console.error(error);
}); src/app/app.module.ts import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { PolymerModule } from '@codebakery/origami';
import { AppElementsModule } from '@codebakery/origami/lib/collections';
import { AppComponent } from './app.component';
import { FeaturesComponent } from './features/features.component';
@NgModule({
imports: [
AppElementsModule,
BrowserModule,
FormsModule,
PolymerModule.forRoot()
],
declarations: [
AppComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent]
})
export class AppModule { } src/app/app.component.ts import { Component } from '@angular/core';
import { PolymerChanges } from '@codebakery/origami';
@Component({
selector: 'app-root',
template: `
<app-drawer class="drawer" id="mainDrawer" swipe-open opened>
<section class="drawer-content">Hello World</section>
</app-drawer>
`
})
export class AppComponent { } I'm testing in Chrome 60.0.3112.24, Firefox 53.0.3, Edge 38.14393.1066.0. All three are working as I expect. The app loads and the drawer is open. Swiping it to open and close work and the styling looks correct for a default Your description of Chrome is accurate, but Firefox is rendering things differently for me. <head>
...
<!-- Not wrapping in <custom-style> -->
<style scope="app-drawer">
app-drawer { ... } /* Not adding :not(.style-scope) */
...
</style>
...
</head>
<body>
...
<!-- This matches what you described with the style-scope and app-drawer classes -->
<app-drawer id="mainDrawer" class="drawer" ...>
<div id="scrim" class="style-scope app-drawer visible" ...></div>
<div id="contentContainer" class="style-scope app-drawer" ...>
<section class="drawer-content">Hello World</section>
</div>
</app-drawer> My suspicion is that you're on an older version of Polymer or ShadyCSS and that you're using If we can get the exact versions you're using for everything, that'll move us one step closer to figuring out what combination of effects are causing this. |
Thank you for the details. I have no place in my code to call And I'm running on:
The only difference is that we're running on different version of Angular. And as I can see through through the screenshots you attached, In my situation, I already confirmed that small fix on Sorry for writing long words with no sample source or screenshot. |
I am also using Firefox v53.0.3 and Edge v14.14393. |
There's got to be some Angular component styles that you haven't mentioned. There's no other way |
I am linking styles to the Angular component by |
I was finally able to reproduce it. It requires a second Angular component with styles to trigger ^ This is kind of why I asked for a full sample repository instead of snippets. It would have been a lot faster to see the details that weren't mentioned in your posts. Your info was good and the problem real, but there were overlooked nuances that made it harder to troubleshoot. I'll work on a patch for this, it shouldn't take long now that I can reproduce it. |
Should be good to go with 1.2.2 now |
@hotforfeature I have gone with v1.2.2 and the patch works fine. Thanks a lot! |
Currently
PolymerDomSharedStylesHost
simply wraps styles in<custom-style>
elements, but it breaksPolymer and other web components implementing ShadowDOM v1 spec on non-Chrome browsers.
Here is an example: Polymer's
app-drawer
componentThis works fine on Chrome and the inspector gives us the following tree:
So
#contentContainer
can get styled byapp-drawer
styling on Chrome. But other browsers don't support ShadowDOM spec and thus ShadyCSS polyfills the component in the following.As you can see,
SelectorA
matchesapp-drawer
(host element), butSelectorB
andSelectorC
can never match#contentContainer
and#scrim
respectively, and eventually#mainDrawer
gets broken.Here is how
app-drawer
is rendered before it's a pre-custom-styled version ofstyle[scope="app-drawer"]
.I am not sure why this happened, but I suppose the component got double polyfilled, the first time polyfilling was done correctly by referring to both of component's template and style, but second time with component polyfilling wrong by referring to only component's style as an individual.
So I suggest: PolymerDomSharedStylesHost should rather apply custom-styling to the only styles defined app-level (document-level style plus Angular components' styles) since origami handles only Angular4 + Polymer2, or at least it can provide the way to point which styles should be custom-styled.
I made changes on origami myself and it worked fine for me. I also committed my changes on a side branch and get ready to contribute my work and time to origami. (I attach a screenshot since I can't push my updates right now due to permission denied to me)
Thank you.
The text was updated successfully, but these errors were encountered: