All pastes #97276 Raw Edit

Something

public text v1 · immutable
#97276 ·published 2006-07-23 14:56 UTC
rendered paste body
=== rdftest.xul ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://rdftest/skin/mybinding.css" type="text/css"?>
<window id="example-window" title="Exemple 9.2.1"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="onLoad()">     
	<script src="rdftest.js" />
	<button label="display" oncommand="onDisplay()" />
	<mytag id="testbinding"/>
</window>

=== rdftest.js ===
function onDisplay() {
	var elem = document.getElementById("testbinding");
	alert(elem.tagName); // works fine => mytag
	alert(elem.nodeName); // works fine => mytag
	elem.myTest(); // javascript error in the console :
        // Error: elem.myTest is not a function
        // Source File: chrome://rdftest/content/rdftest.js
}

=== mybinding.css ===
mytag {
    -moz-binding: url('chrome://rdftest/skin/mybinding.xml#mybinding');
}

=== mybinding.xml ===
<?xml version="1.0" encoding="iso-8859-1"?>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

	<binding id="mybinding">
	  	<content>
			<xul:button label="pouet"/>
	  	</content>
	  	
	  	<implementation>
	  		<constructor>
	  			alert("blah");
	  		</constructor>
	  		<method name="myTest">
	  			<parameter name="message"/>
		  		<body>
			  		<![CDATA[
			  			alert("blah " + message);
			  			document.getAnonymousNodes(this)[0].setAttribute("label", message);
			  		]]>
		  		</body>
		  	</method>
	  	</implementation>
	</binding>

</bindings>