{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/16670","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/16670/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/16670/comments","events_url":"https://api.github.com/repos/angular/angular/issues/16670/events","html_url":"https://github.com/angular/angular/issues/16670","id":227526666,"node_id":"MDU6SXNzdWUyMjc1MjY2NjY=","number":16670,"title":"Styles are not removed by router after navigation when using ViewEncapsulation.None","user":{"login":"kyledevans","id":1494609,"node_id":"MDQ6VXNlcjE0OTQ2MDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1494609?v=4","gravatar_id":"","url":"https://api.github.com/users/kyledevans","html_url":"https://github.com/kyledevans","followers_url":"https://api.github.com/users/kyledevans/followers","following_url":"https://api.github.com/users/kyledevans/following{/other_user}","gists_url":"https://api.github.com/users/kyledevans/gists{/gist_id}","starred_url":"https://api.github.com/users/kyledevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyledevans/subscriptions","organizations_url":"https://api.github.com/users/kyledevans/orgs","repos_url":"https://api.github.com/users/kyledevans/repos","events_url":"https://api.github.com/users/kyledevans/events{/privacy}","received_events_url":"https://api.github.com/users/kyledevans/received_events","type":"User","site_admin":false},"labels":[{"id":375500771,"node_id":"MDU6TGFiZWwzNzU1MDA3NzE=","url":"https://api.github.com/repos/angular/angular/labels/comp:%20router","name":"comp: router","color":"c7def8","default":false},{"id":375497245,"node_id":"MDU6TGFiZWwzNzU0OTcyNDU=","url":"https://api.github.com/repos/angular/angular/labels/freq3:%20high","name":"freq3: high","color":"fbca04","default":false},{"id":375498203,"node_id":"MDU6TGFiZWwzNzU0OTgyMDM=","url":"https://api.github.com/repos/angular/angular/labels/severity3:%20broken","name":"severity3: broken","color":"0052cc","default":false},{"id":130606843,"node_id":"MDU6TGFiZWwxMzA2MDY4NDM=","url":"https://api.github.com/repos/angular/angular/labels/type:%20bug/fix","name":"type: bug/fix","color":"EEEEEE","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/angular/angular/milestones/82","html_url":"https://github.com/angular/angular/milestone/82","labels_url":"https://api.github.com/repos/angular/angular/milestones/82/labels","id":3045967,"node_id":"MDk6TWlsZXN0b25lMzA0NTk2Nw==","number":82,"title":"Backlog","description":"Milestone for triaged issues that have not yet been scheduled for resolution.","creator":{"login":"IgorMinar","id":216296,"node_id":"MDQ6VXNlcjIxNjI5Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/216296?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"open_issues":1981,"closed_issues":541,"state":"open","created_at":"2018-01-18T16:52:20Z","updated_at":"2018-11-21T00:36:40Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2017-05-09T23:28:24Z","updated_at":"2018-11-21T14:10:16Z","closed_at":null,"author_association":"NONE","body":"**I'm submitting a ...**  (check one with \"x\")\n```\n[X] bug report => search github for a similar issue or PR before submitting\n[ ] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\nIf a component uses ViewEncapsulation.None then those styles are never removed from the DOM after the user navigates to a different route.  For example if component Foo styles the `<p>` tag with a red background, and then the user navigates to a different route, all `<p>` tags on the next page will have a red background.\n<!-- Describe how the bug manifests. -->\n\n**Expected behavior**\nStyles should not outlive the component that defines them.  A `<p>` tag should look the same, no matter what the routing history is.\n\n**Minimal reproduction of the problem with instructions**\n1. Create 2 routes \"Foo\" and \"Bar\".\n2. Configure the main component for Foo so that it uses ViewEncapsulation.None.\n3. Create a `<p>` elements in both the Foo and Bar components.\n4. In the component for Foo, create a style `p { background-color: #F00; }`.\n5. In the main application component create some routerLinks to allow navigation between the Foo and Bar routes.\n6. Run the application\n7. Click on the link for \"Foo\".  Note the red background on the `<p>` element.  This is expected.\n8. Click on the link for \"Bar\".  Note that the `<p>` element is red.  This is NOT expected.\n9. Refresh the page.\n10. Click on the link for \"Bar\".  Note that this time the `<p>` element is not red.\n11. Navigate to \"Foo\" then go back to \"Bar\".  The `<p>` element is now red again.  This is NOT expected.\n\n**Plnker**\n\n1. [Plnker](http://plnkr.co/edit/nG8gSD4Xc492ceIGlAeC?p=preview)\n2. In the plunker, click on the \"Foo\" link first.\n3. Then click on the \"Bar\" link.  Note the red `<p>` tag.  This is NOT expected.\n4. Refresh the page, click on the \"Foo\" link.  Note the red `<p>` tag.  This is expected.\n5. Click on the \"Bar\" link.  Then click on \"Foo\" again.  Note the red `<p>` tag.  This is NOT expected.\n\n**What is the motivation / use case for changing the behavior?**\nFor every page/component that is rendered into the `<router-outlet>`, I will configure it so that it uses ViewEncapsulation.None.  This allows me define semi-global styles for individual pages.  So for example if I want all `<input>` tags to have 200px width only on page Foo, I can just set the style in the FooComponent stylesheet.\n\nI shouldn't have to worry that styles on page Foo can bleed over into page Bar.  Worse is that this effect is entirely dependent on the exact order that the user navigates around the application.  For any non-trivially sized application, this represents an unreasonable testing burden.  For the moment I have decided that it's best that I don't use the angular router when navigating between \"feature pages\" and fallback to conventional `<a>` links.\n\n**Please tell us about your environment:**\nWindows 10. Angular CLI and Notepad++, npm\n\n* **Angular version:** 2.0.X\nAngular 4.1.1.  This may impact older versions, but I wouldn't have seen it until today because I normally don't navigate between feature pages in my application without performing a full page load.  I just happened to forget to do it this one time.\n\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]\nChrome, Firefox, Edge.  Haven't tested others.\n \n* **Language:** [all | TypeScript X.X | ES6/7 | ES5]\nTypeScript\n\n* **Node (for AoT issues):** `node --version` ="},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/440674451","html_url":"https://github.com/angular/angular/issues/16670#issuecomment-440674451","issue_url":"https://api.github.com/repos/angular/angular/issues/16670","id":440674451,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDY3NDQ1MQ==","user":{"login":"trotyl","id":6059170,"node_id":"MDQ6VXNlcjYwNTkxNzA=","avatar_url":"https://avatars0.githubusercontent.com/u/6059170?v=4","gravatar_id":"","url":"https://api.github.com/users/trotyl","html_url":"https://github.com/trotyl","followers_url":"https://api.github.com/users/trotyl/followers","following_url":"https://api.github.com/users/trotyl/following{/other_user}","gists_url":"https://api.github.com/users/trotyl/gists{/gist_id}","starred_url":"https://api.github.com/users/trotyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trotyl/subscriptions","organizations_url":"https://api.github.com/users/trotyl/orgs","repos_url":"https://api.github.com/users/trotyl/repos","events_url":"https://api.github.com/users/trotyl/events{/privacy}","received_events_url":"https://api.github.com/users/trotyl/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T14:10:16Z","updated_at":"2018-11-21T14:10:16Z","author_association":"CONTRIBUTOR","body":"> What's the purpose of `ViewEncapsulation.None` then?\r\n\r\nIt's for performance consideration, which avoids extra attributes on element in rendering or regex replacement:\r\n\r\nhttps://github.com/angular/angular/blob/cf0968f98e844043a0f6c2548201f3c0dfd329a7/packages/compiler/src/directive_normalizer.ts#L186-L189\r\n\r\nSo if you can make sure that it won't have any side-effect then you can use it for better performance."}}
{"actor":{"display_login":"trotyl"}}