Closed Bug 180504 Opened 22 years ago Closed 21 years ago

xbl:inherits breaks when inherited attribute is removed

Categories

(Core :: XBL, defect)

x86
Other
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: WeirdAl, Assigned: hyatt)

Details

(Keywords: dom1, testcase)

Attachments

(4 files, 3 obsolete files)

When you have a default attribute in XBL, and XBL also directs the inheritance 
of that attribute through xbl:inherits, the Core DOM can make things 
interesting.

(1) Without the inherited attribute initially, XBL defaults to the attribute 
value defined in the XBL document.
(2) Using setAttribute in the XUL document (I haven't built an HTML testcase), 
the default attribute value in the XBL document is overridden by the XUL 
document's attribute, which it inherits (correctly).
(3) Using removeAttribute in the XUL document to remove the overriding 
attribute, the XBL document fails to revert to the default attribute.

Testcase coming up via three attachments.
Attached file Testcase (part 3 of 3) -- XUL document (obsolete) —
Open this attachment to see the testcase, then follow the directions embedded
within.
Attached file Testcase (part 3 of 3) -- XUL document (obsolete) —
ML stylesheet didn't apply -- trying with stylesheet PI in the right place.
Attachment #106517 - Attachment is obsolete: true
Attached file Testcase as ZIP
Bugzilla doesn't like me today.  Sorry for all the spam.  This testcase is
localized, so you simply unzip all three files into the same directory.
Attachment #106515 - Attachment is obsolete: true
Attachment #106516 - Attachment is obsolete: true
Attachment #106518 - Attachment is obsolete: true
Attached file Testcase (part 3 of 3) -- XUL document (obsolete) —
Per bz's insistence, one more try (with & escaped).
Argh.  Bugzilla doesn't like me because it doesn't like stupid mistakes.
Attachment #106521 - Attachment is obsolete: true
Attachment #106515 - Attachment is obsolete: false
Comment on attachment 106516 [details]
Testcase (part 2 of 3) -- CSS stylesheet for binding

Last bit of stupid bugspam for a while.  Major apologies to all concerned.
Attachment #106516 - Attachment is obsolete: false
Sorry if I haven't been clear:  this bug forces, in the XUL document, a
violation of the DOM Level 1 Core specification under Element.removeAttribute. 
From that specification, the exact words are:

removeAttribute
    Removes an attribute by name. If the removed attribute is known to have a
default value, an attribute immediately appears containing the default value.

I believe Mozilla "knows" via XBL a default value for the context attribute in
the testcase, and that is my justification for this bug.  If I'm wrong, I'm wrong.
Keywords: dom1
Interesting XBL spec question. I know the spec right now says that any change to
an inherited attribute is reflected into the anonymous content/attribute we're
inheriting into, including removeAttribute. It kinda makes sense though to think
of this combo as default + override, where removing the override would take you
back to the "default" value:

<foo id="fooEl"/>

<binding id="foo">
  <content>
    <bar a="1" xbl:inherits="a"/>
    <children/>
  </content>
</binding

// begin with <bar a="1"/>
fooEl.setAttribute("a", "2"); // --> <bar a="2"/>
fooEl.removeAttribute("a"); // --> <bar a="1"/> (and not <bar/>)



As a side question, what does this do:

<foo id="fooEl"/>

<binding id="foo">
  <content a="1" xbl:inherits="a"> <!-- rather nonsensical -->
    <children/>
  </content>
</binding>

// begin with <foo id="fooEl" a="1"/>
fooEl.setAttribute("a", "2"); // --> infinite loop?

Should xbl:inherits be disallowed on <content/>? Is it currently ignored?
The current behavior of XBL (the way it works now) is correct.  If you specify
an attribute along with xbl:inherits in the XBL template, it represents an
initial value only (a value that should be used if it isn't overridden by the
bound element).  It's an initial value and not a default value.

The concept of "default values" with XML and the DOM is something totally
different.  This is getting into XML schema territory, where it is the province
of the language itself (e.g., the XUL schema) to specify what the default values
for attributes are in XUL.
invalid per hyatt's comment.  Thanks.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: