Closed Bug 276087 Opened 20 years ago Closed 20 years ago

DOMAttrModified event isn't fired on binding

Categories

(Core :: DOM: Events, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: surkov, Unassigned)

Details

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a5) Gecko/20041122
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a5) Gecko/20041122

I declare two bindings:

<binding id="binding1">
<content>
	<xul:textbox xbl:inherits="value=attr"/>
</content>
<handlers>
	<handler event="DOMAttrModified">
		alert("binding1"+event.attrName+"!"+event.attrNewValue);
	</handler>
</handlers>
</binding>

<binding id="binding2">
<content>
	<xul:binding1 xbl:inherits="attr"/>
</content>
<handlers>
	<handler event="DOMAttrModified">
		alert("binding2"+event.attrName+"!"+event.attrNewValue);
	</handler>
</handlers>
</binding>

I create:

<binding2 attr="2"/>

Event DOMAttrModified is fired for textbox but it isn't fired for binding1.

Reproducible: Always

Steps to Reproduce:
I will say about strange behaviour of DOMAttrModified event. I don't know is it
different bugs or one the same.

I try:

<binding id="binding1">
<content>
	<xul:textbox/>
</content>
<implementation>
	<constructor>
		this.setAttribute('attr', this.getAttribute('attr'));
	</constructor>
</implementation>
<handlers>
	<handler event="DOMAttrModified">
		alert(event.attrName+"!"+event.newValue);
	</handler>
</handlers>
</binding>

<binding id="binding2">
<content>
	<xul:binding1 xbl:inherits="attr"/>
</content>
</binding>

When I create binding1 then DOMAttrModified is fired. When I create binding2
then DOMAttrModified is not fired.
question: should DOMAttrModified event be fired for binding in the next case?

<binding1>
<content>
  <xul:textbox/>
</content>
<handlers>
  <handler event="DOMAttrModified">
     alert(event.newValue);
  </handler>
</handlers>
</binding>

<binding1 attr="4"/>

DOMAttrModified isn't fired when binding1 is created. Is it correct behaviour?
Alexander, could you attach an actual testcase showing the problem?
Attached file bindings
Attached file styles
Attached file testcase for comment#0
DOMAttrModified is not fired for some elements in bindings (like xul:hbox) when
anonymous element has attribute or inherits it by xbl:inherits attribute. 
If I replace box with textbox then DOMAttrModified is changed.
There should be no event firing for <xul:box attr="hello"/> (since the attribute
is set before there event handler is hooked up).

The event for <xul:box xbl:inhertis="attr"/> might fire if you spell "inherits"
correctly.

The events you see for the textboxes are probably for the "value" attribute, not
the "attr" attribute.
OK, attrs set via inherits are set before the event listeners are hooked up. 
This makes sense, imo... Neil, thoughts?
There is a mutation event fired when a textbox is bound. However, this isn't
caused by the textbox binding, it's actually caused by the textbox's context
menu which sets the textbox's context attribute to "_child" if it's unset. But
this is an attribute change on an element that's already in the document.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Such behaviour is awkward. Why you don't want to hook up handlers before loading
content? Is it impossible? If I want to watch attributes changing then I want to
do it in one place. 

I suppose that answer of #comment2 question is 'no'. I belive it is awkard but
it is unachievable (because dom node is created before the binding).
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Hooking up handlers before setting up the content would be a pretty major
behavior change.  I don't think we can do that sort of thing at this point
without breaking compat with existing XBL content.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago20 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: