-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Is AngularJS messing up with CSS :target selectors? #8478
Comments
Which version of AngularJS did you upgrade to in noticing this issue? How are you trying to apply styles to |
Lots of info is missing, if you could provide some details that would be helpful. |
Ok, I am using AngularJS's npm package at https://www.npmjs.org/package/angular (current version is 1.2.19) Then, here an example of the CSS I am trying: ul#changelog li:target {
background: #008000;
} the html code is <ul id="changelog" class="ng-scope">
<li id="0.1.1">
<h3 class="version"><a href="#0.1.1">Version 0.1.1</a> [current]</h3>
<ul>
<li>[feature] ...</li>
</ul>
</li>
<li id="0.1.0">
<h3 class="version"><a href="#0.1.0">Version 0.1.0</a></h3>
<ul>
<li>[feature] Revamp ...</li>
<li>[feature] ...</li>
</ul>
</li>
</ul> Fails on latest Firefox and Chrome. When I browse to Without AngularJS it works fine. |
Seems to be working here http://plnkr.co/edit/E1dscGK7SO6SKtMnqt6C?p=preview Please post a full reproduction (plnkr should work, but github is fine if you need that instead) |
Thanks @caitp but you also should wrap the body with |
again, please post a full reproduction of your issue! package it! put it on the internets! |
Well, it's a private repo ... in that case I could make you a collaborator so that you can git pull it. Would you do that? |
you can squeeze it down to something that you can show publicly, that would be best. |
ok, will set up something soon on my server, stay tuned |
Hi @binarykitchen it'd be a lot more helpful if you could reduce the code to something that fits in a plunker, rather than requiring reviewing on your server. |
Okay @jeffbcross @caitp here is a reduced code on plunker: If you remove the The script itself is generated by browserify - on the top it's AngularJS, at the bottom you'll find the application-specific code. I removed anything obsolete to keep it as small as possible. I hope this helps locating the bug! |
It works as expected if you change the tags in your template to use |
I believe I know the commit which caused this, and we are likely to revert it --- but when you expect the browser to do it's regular browser thing when you click links, you should use target="_self" anyways. |
also, please try to avoid using requirejs for future reproductions, it's a lot easier to see what's going on in your app (and test against other versions of angular) if you just include your application code, and link to angular seperately. |
Hmm, I added Regarding reproduction, I agree. But if I remove browserify, then I'd have too many JS files to add. Can you point me a link to the commit you believe caused this? |
Did you add Because that's what I had to do to make it work |
Also, I think this might be fixed if we land #8492 --- it would be helpful if you tried a build of angular from that commit and see if that helps you |
Oh right, I forgot the templateCache. Works now. http://plnkr.co/edit/N68dpnGCbl7eYsbdXnN8?p=preview But there is a new problem:
Looks like Angular is swallowing some events here. Look at https://videomail.io/versions#0.0.27 - this is the behaviour I want (currently without Angular). (the templateCache is a trick to reduce the number of queries to the server. I am compiling the jade templates into that cache via Gulp) |
and yes, if you email or post me an angular build with your commit i will test this for sure! |
we might be swallowing the events anyways, but you can get it at http://ci.angularjs.org/job/angular.js-caitlin/456/artifact/build/ |
okay, tested with your builds. but the problem described in my comment above #8478 (comment) still exists. i am afraid AngularJS is still messing up with these events ... |
for example if i open the page for the first time with |
okay --- i'm not sure if this is really fixable at all in hashbang mode, but I think it will always work in html5 mode in browsers which support history? At any rate it seems hard to write a non-e2e test for this one @_@ |
@binarykitchen you're welcome to come up with a patch for this btw, I think it comes down to just aborting if we determine the clicked href value is a "real" hash (IE not a LocationHashbangUrl virtual path) --- that part seems trivial, and it is related to a number of other issues open regarding $location (#772, #4608, sorta #5532, #5529, maybe others) |
yeah, looks like these other issues are related to this one. i am afraid i am not that angular-experienced enough to patch angular for this. but i hope someone will in the near future. many thanks for your assistance so far @caitp |
Okay, I'll see if I can write something for this. |
$location will no longer rewrite hash fragment links in the same document (specified via href="#hash..."). Closes angular#8478
@binarykitchen you might try again using the build from http://ci.angularjs.org/job/angular.js-caitlin/457/artifact/build/ |
I tried and I am afraid, it is still not working with my prototype :( |
Best is to copy the HTML code from https://videomail.io/versions#0.0.27 and trying to reproduce exactly the same behavior when AngularJS comes into play. |
http://plnkr.co/edit/WVPYzaXOKujcb5vSbvJz?p=preview seems to be working here |
aww I'm wrong, okay, looking into it. (it works if you don't inject $location, breaks if you do) |
okay, I think I know how to fix that :> (we do want to rewrite links which start with the hash prefix, like |
$location will no longer rewrite hash fragment links in the same document (specified via href="#hash..."). Closes angular#8478
Yeah, works now http://plnkr.co/edit/WVPYzaXOKujcb5vSbvJz?p=preview |
Yes, that's the behavior I want. But if you add HTML5 mode, it fails. See my plunker at Hope you can adjust the code further to make it work on HTML5 mode as well? |
Still works, there's just a syntax error in that updated plunk. |
Okay, will add more code. Is there a way to see console errors in plunker? |
Have extended your plunker with the router and not it doesn't work You have to click twice on a link to make the CSS selector work. |
Maybe the bug is related to the $routeProvider ? |
There's a problem in $routeProvider which manifests in requiring the link to be clicked twice (with the patch), but that's a separate bug to be fixed separately imo |
Ok! Should we open a new bug report for the $routeProvider in this tracker? |
@caitp ?? |
@binarykitchen sorry I never got the message when you sent it. Yes, please file! |
The patch I wrote for this didn't land, but it seems to be fixed by 2294880 |
sorry, i cannot remember what to report here and where to. this ticket is pretty old ... |
|
if your patch does fix this, then all should be good now |
my patch had nothing whatsoever to do with the ngRoute issue, which is why I said you should file a bug about it! anyways, alright don't worry about it |
The :target selectors works fine finally? Check this out : Drawer code and this is my proyect(works fine with $anchorScroll and target="_self" but i think this not a very good solution) |
Looks like I cannot apply styles to
:target
selectors anymore. Is this because of AngularJS?The text was updated successfully, but these errors were encountered: