This project is archived and is in readonly mode.

#28 ✓wontfix
Thomas Aylott

FX.CSS.search - browser compatibility

Reported by Thomas Aylott | May 28th, 2008 @ 10:05 AM

Originally posted on Trac by mattcoz

Original Trac Ticket

Description

There are some issues with how the different browsers deal with the stylesheet rules objects. In the instance of a rule like this:

a:link

Most browsers will handle it correctly, but IE stores it as:

A:link

The easy solution is to change the regular expression check to case insensitive, but that wouldn't be standards compliant as class names are case sensitive. I guess we would have to find and change all tag names to upper case when IE is being used.

Another issue is rules like this:

a:link, a:hover

IE splits it up into separate entries, but other browsers keep it as one which causes the match to fail. This one is actually simple to fix, just change the regexp check to this:

'(^|, )' + selector + '(,|$)'

I've tested this in Firefox, Opera, Safari, and IE.

I'll get a patch put together that will deal with these two issues.

Trac Attachments

Trac Comments

Changed 4 months ago by kamicane



                  Changed 4 months ago by kamicane

          milestone
              changed from Mootools version 1.2 to Mootools version 1.3

          milestone
              changed from Mootools version 1.2 to Mootools version 1.3
        
      

Changed 3 months ago by mattcoz


        
I noticed that you attempted to fix this in a recent update, so I've changed the milestone back to 1.2 for further discussion.  I've done some work on this problem since I opened the ticket and what I came up with is a 3 step solution: 

1. Fix white-space around combinators.  Selectors such as a>b will fail and must be changed to a > b. 

selector = selector.replace(/\s*(\+|>|~(?!=))\s*/g, ' $1 '); 

2. Fix IE issue with upper case element names.  Element names can be found by character strings that are preceded by white-space. 

if (Browser.Engine.trident) selector = selector.replace(/(?:^|\s+)[a-z]+/g, String.toUpperCase); 

3. Match multiple selector lists.  I've updated my code to use the regexp from your update. 

selector = new RegExp('(?:^|,\\s*)' + selector.escapeRegExp() + '(?=\\s*,|$)'); 

It is not perfect though, as a selector such as a[attr="string value"] will cause problems.  Have any ideas about that? 

                  Changed 3 months ago by mattcoz

          milestone
              changed from Mootools version 1.3 to Mootools version 1.2

I noticed that you attempted to fix this in a recent update, so I've changed the milestone back to 1.2 for further discussion.  I've done some work on this problem since I opened the ticket and what I came up with is a 3 step solution: 

1. Fix white-space around combinators.  Selectors such as a>b will fail and must be changed to a > b. 

selector = selector.replace(/\s*(\+|>|~(?!=))\s*/g, ' $1 '); 

2. Fix IE issue with upper case element names.  Element names can be found by character strings that are preceded by white-space. 

if (Browser.Engine.trident) selector = selector.replace(/(?:^|\s+)[a-z]+/g, String.toUpperCase); 

3. Match multiple selector lists.  I've updated my code to use the regexp from your update. 

selector = new RegExp('(?:^|,\\s*)' + selector.escapeRegExp() + '(?=\\s*,|$)'); 

It is not perfect though, as a selector such as a[attr="string value"] will cause problems.  Have any ideas about that? 

          milestone
              changed from Mootools version 1.3 to Mootools version 1.2
        
      

Changed 2 months ago by digitarald


        
A fix would be to only allow simple selectors without spaces or other combinators. A regexp for replacing tags in combined selectors is not possible without a lot of code and a similar logic as the old Selector.parse. 

Thats why we will fix it after 1.2 

                  Changed 2 months ago by digitarald

          owner
              set to digitarald
        
          milestone
              changed from Mootools version 1.2 to Mootools version 1.3

A fix would be to only allow simple selectors without spaces or other combinators. A regexp for replacing tags in combined selectors is not possible without a lot of code and a similar logic as the old Selector.parse. 

Thats why we will fix it after 1.2 

          owner
              set to digitarald
        
          milestone
              changed from Mootools version 1.2 to Mootools version 1.3
        
      

Changed 2 weeks ago by tomocchino



                  Changed 2 weeks ago by tomocchino

          priority
              changed from major to minor
        
          milestone
              set to Mootools version 1.3

          priority
              changed from major to minor
        
          milestone
              set to Mootools version 1.3
        
      

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Attachments

Tags

Referenced by

Pages