MozillaZine

styling of bgsound disabled?

Discussion of bugs in Mozilla Firefox
em_te

User avatar
 
Posts: 342
Joined: June 13th, 2004, 1:03 am
March 1st, 2005, 10:38 pm

Post Posted March 1st, 2005, 10:38 pm

It seems to be impossible to style the "bgsound" tag in Firefox, but it seems to be possible to style non-existent tags. Anyone know why? AFAIK, the bgsound tag is not supported in Firefox, so it shouldn't interfere with normal CSS styling.

Code: Select all
<html>

<style type="text/css">
  bgsound, doesnt, exist
  {
    font-weight: bold;
  }
</style>

<body>
  <br>is <bgsound>bgsound</bgsound>
  <br>is <doesnt>doesnt</doesnt>
  <br>is <exist>exist</exist>
</body>

</html>


displays as:
==
is bgsound
is doesnt
is exist
==
Anyone know why?
Last edited by em_te on March 1st, 2005, 11:21 pm, edited 1 time in total.

em_te

User avatar
 
Posts: 342
Joined: June 13th, 2004, 1:03 am
March 1st, 2005, 11:21 pm

Post Posted March 1st, 2005, 11:21 pm

I just did some more testing and it seems that the "bgsound" tag isn't even in the hierarchy. How odd:
Code: Select all
<html>
<style type="text/css">
aa > aa
{
  font-weight: bold;
}
</style>

<body>
<aa><bgsound><aa>shouldn't be bold</aa></bgsound></aa>

<aa><bb><aa>shouldn't be bold</aa></bb></aa>

<aa><aa>bold</aa></aa>
</body>
</html>


looks like:
==
shouldn't be bold
shouldn't be bold
bold
==

And if I do:
Code: Select all
alert(document.getElementsByTagName("aa")[0].firstChild.tagName);

it returns "AA".

Atropos

User avatar
 
Posts: 1116
Joined: December 4th, 2002, 6:18 pm
Location: Texas
March 1st, 2005, 11:41 pm

Post Posted March 1st, 2005, 11:41 pm

Pfft. Invented by Microsoft. Have you not read what their documentation says??!

Microsoft wrote:Remarks

The BGSOUND element can appear anywhere within the document.

This element is available in HTML as of Internet Explorer 3.0, and in script as of Internet Explorer 4.0.

This element is not rendered.

This element does not require a closing tag.

Standards Information

This object is a Microsoft extension to HTML Non-Microsoft link.
(emphasis mine)

So apparently the styling is supposed to be disabled by design. So it seems to not be a bug, unless you think this deprecated, unsupported propietary element should not be handled specially at all.

The actual behavior is that the bgsound element is considered to by a child of the head element, and gets moved there if found outside the head. I spent 30 minutes looking in the source to discover that when all one had to do was use the DOM Inspector to see it in action. Apparently the end tag is ignored.

em_te

User avatar
 
Posts: 342
Joined: June 13th, 2004, 1:03 am
March 2nd, 2005, 12:14 am

Post Posted March 2nd, 2005, 12:14 am

Atropos wrote:So apparently the styling is supposed to be disabled by design. So it seems to not be a bug, unless you think this deprecated, unsupported propietary element should not be handled specially at all.

The actual behavior is that the bgsound element is considered to by a child of the head element, and gets moved there if found outside the head. I spent 30 minutes looking in the source to discover that when all one had to do was use the DOM Inspector to see it in action. Apparently the end tag is ignored.

That discovery intrigues me. I've never seen tags move around before automatically as part of the parsing process (other than simple normalization).

I expected the "bgsound" tag not to be handled specially since Firefox doesn't support it. And even if it did, I would expect it to be handled similar to "embed" rather than something like meta tags.

Even though Microsoft says that the tag is not rendered, I still thought you could style it just like how you could style an image "map" or hidden input fields.

mw
 
Posts: 2378
Joined: November 19th, 2002, 5:37 pm
March 2nd, 2005, 1:35 am

Post Posted March 2nd, 2005, 1:35 am

Hmm, this looks indeed strange to me. Why should the <bgsound> tag be moved? Mozilla doesn't support it, so I think this should be treated like any other unknown tag.
See:
long url

This code was added to fix these two bugs:
https://bugzilla.mozilla.org/show_bug.cgi?id=28208
https://bugzilla.mozilla.org/show_bug.cgi?id=3944
according to the comments of bonsai then, however I don't really see what bug 3944 has got to do with this behavior at least.

edit:
Well, IE is doing the same, so probably that's a good enough a reason to do it also.

edit edit:
No, IE is not doing the same, the bgsound stays on it's spot, so this is -imho- a Mozilla bug.

Atropos

User avatar
 
Posts: 1116
Joined: December 4th, 2002, 6:18 pm
Location: Texas
March 2nd, 2005, 4:56 pm

Post Posted March 2nd, 2005, 4:56 pm

mw wrote:No, IE is not doing the same, the bgsound stays on it's spot, so this is -imho- a Mozilla bug.


OK, so in conclusion:

1. BGSOUND element moved to HEAD: bug, but by deisgn to fix some other bug;
2. No style on BGSOUND: not a bug, this element is not a container and thus no end tag and has no layout since it for "background sound" not visual content.

IE 6 does not treat BGSOUND element as a container and applies no style as well.

Code: Select all
<html>
<head>
<style type="text/css">
bgsound {
   font-weight: bold;
}
</style>
<script type="text/javascript">
function getElements() {
   var bgs = document.getElementById('sound');
   var msg = document.getElementById('message');
   msg.appendChild(
      document.createTextNode(
         bgs.tagName + '#' + bgs.id + ' has ' +
         bgs.childNodes.length + ' children'
      )
   );
}
</script>
</head>
<body onload="getElements()">
  <p>
    Normal
    <bgsound id="sound"> (not) Bold </bgsound>
    Normal
    </p>
  <p id="message"></p>
</body>
</html>

mw
 
Posts: 2378
Joined: November 19th, 2002, 5:37 pm
March 3rd, 2005, 1:17 am

Post Posted March 3rd, 2005, 1:17 am

Thanks Atropos!

IE doesn't make sense.
Try with your example this:
<button onclick="alert(document.getElementsByTagName('p')[0].innerHTML);">alert</button>

My opinion is, that since Mozilla doesn't support the <bgsound> tag, it should not 'do' anything with it and treat it like any other unknown tag.

Atropos

User avatar
 
Posts: 1116
Joined: December 4th, 2002, 6:18 pm
Location: Texas
March 3rd, 2005, 5:04 am

Post Posted March 3rd, 2005, 5:04 am

mw wrote:IE doesn't make sense.


IE is thinking there are 5 children of the P element, since in IE the BGSOUND element is not moved, and also there is no closing tag for it. So you end up with text node, element node, text node, element node, text node.

Firefox on the other hand actually acts as if the the bgsound tags were not there at all, and collapses all 3 words into a single text node as a result.

Code: Select all
<html>
<head>
<script type="text/javascript">
function getElements() {   
   var msg = document.getElementById('message');
   var bgs = document.getElementById('first');
   for (i=0; i < bgs.childNodes.length; i++) {
      n = bgs.childNodes[i];
      if (n.nodeType == 3) {
         s = 'text: ' + n.nodeValue;
      }
      else if (n.nodeType == 1) {
         s = 'element: ' + n.tagName;
      }
      else {
         s = 'unknown: type ' + n.nodeType;
      }
      msg.appendChild(document.createTextNode(s));
      msg.appendChild(document.createElement('br'));
   }
}
</script>
</head>
<body onload="getElements()">
  <p id="first">
    Normal
   <bgsound id="sound">Bold</bgsound>
    Normal
    </p>
  <p id="message"></p>
</body>
</html>

Firefox output:
Code: Select all
Normal Bold Normal

text: Normal Bold Normal

IE output:
Code: Select all
Normal Bold Normal

text: Normal
element: BGSOUND
text: Bold
element: /BGSOUND
text:  Normal

Return to Firefox Bugs


Who is online

Users browsing this forum: No registered users and 5 guests