Opera bug - existing attributes on wrong tag

Bug solved in Opera 7.60 beta.

The getAttribute() method allows you to read out any attribute from any tag. Except in Opera, which refuses existing attributes on the wrong tag.

When using custom attributes to trigger scripts I prefer to use existing attributes, even if on the wrong tag. For instance, in my JavaScript Image Replacement script I wanted to use a src attribute to point to the image that should replace a header. Unfortunately Opera could not find this src attribute, so I was forced to use replace (first version, now offline) or a simple id (current version).

Note the replace attribute: it does not exist at all, and therefore Opera accepts it anywhere. Odd but true.

Test

The test paragraph below has a rel attribute, as do the <b> and <a> inside it. Try reading them out:

  1. Read out P
  2. Read out B
  3. Read out A

This is the test paragraph. It contains a bold bit of text and a link.

If you use Opera 7.54 or below you'll see that it cannot detect the rel attribute on the <p> or <b>.