in partnership with mediatemple

Ticket #672 (new defect)

Opened 5 months ago

Last modified 2 days ago

FX.CSS.search - browser compatibility

Reported by: mattcoz Owned by: digitarald
Type: defect Priority: minor
Milestone: Mootools version 1.3 Component: Core
Keywords: Fx CSS Cc:

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.

Change History

Changed 3 months ago by kamicane

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Changed 2 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?

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

Changed 2 days ago by tomocchino

  • priority changed from major to minor
  • milestone set to Mootools version 1.3
Note: See TracTickets for help on using tickets.