merge m-c to fx-team

This commit is contained in:
Tim Taubert 2013-05-23 20:55:32 +02:00
commit b5412862c3
3 changed files with 15 additions and 23 deletions

View File

@ -4,16 +4,11 @@
var kMaxChunkDuration = 30; // ms var kMaxChunkDuration = 30; // ms
var escape = document.createElement('textarea');
function escapeHTML(html) { function escapeHTML(html) {
escape.innerHTML = html; var pre = document.createElementNS("http://www.w3.org/1999/xhtml", "pre");
return escape.innerHTML; var text = document.createTextNode(html);
} pre.appendChild(text);
return pre.innerHTML;
function unescapeHTML(html) {
escape.innerHTML = html;
return escape.value;
} }
RegExp.escape = function(text) { RegExp.escape = function(text) {

View File

@ -10,8 +10,7 @@ this.EXPORTED_SYMBOLS = ["SplitView"];
/* this must be kept in sync with CSS (ie. splitview.css) */ /* this must be kept in sync with CSS (ie. splitview.css) */
const LANDSCAPE_MEDIA_QUERY = "(min-width: 551px)"; const LANDSCAPE_MEDIA_QUERY = "(min-width: 551px)";
const BINDING_USERDATA = "splitview-binding"; let bindings = new WeakMap();
/** /**
* SplitView constructor * SplitView constructor
@ -115,7 +114,7 @@ SplitView.prototype = {
} }
if (this._activeSummary) { if (this._activeSummary) {
let binding = this._activeSummary.getUserData(BINDING_USERDATA); let binding = bindings.get(this._activeSummary);
if (binding.onHide) { if (binding.onHide) {
binding.onHide(this._activeSummary, binding._details, binding.data); binding.onHide(this._activeSummary, binding._details, binding.data);
@ -129,7 +128,7 @@ SplitView.prototype = {
return; return;
} }
let binding = aSummary.getUserData(BINDING_USERDATA); let binding = bindings.get(aSummary);
aSummary.classList.add("splitview-active"); aSummary.classList.add("splitview-active");
binding._details.classList.add("splitview-active"); binding._details.classList.add("splitview-active");
@ -147,7 +146,7 @@ SplitView.prototype = {
get activeDetails() get activeDetails()
{ {
let summary = this.activeSummary; let summary = this.activeSummary;
return summary ? summary.getUserData(BINDING_USERDATA)._details : null; return summary ? bindings.get(summary)._details : null;
}, },
/** /**
@ -193,7 +192,7 @@ SplitView.prototype = {
binding._summary = aSummary; binding._summary = aSummary;
binding._details = aDetails; binding._details = aDetails;
aSummary.setUserData(BINDING_USERDATA, binding, null); bindings.set(aSummary, binding);
this._nav.appendChild(aSummary); this._nav.appendChild(aSummary);
@ -258,7 +257,7 @@ SplitView.prototype = {
this.activeSummary = null; this.activeSummary = null;
} }
let binding = aSummary.getUserData(BINDING_USERDATA); let binding = bindings.get(aSummary);
aSummary.parentNode.removeChild(aSummary); aSummary.parentNode.removeChild(aSummary);
binding._details.parentNode.removeChild(binding._details); binding._details.parentNode.removeChild(binding._details);
@ -289,7 +288,7 @@ SplitView.prototype = {
*/ */
setItemClassName: function ASV_setItemClassName(aSummary, aClassName) setItemClassName: function ASV_setItemClassName(aSummary, aClassName)
{ {
let binding = aSummary.getUserData(BINDING_USERDATA); let binding = bindings.get(aSummary);
let viewSpecific; let viewSpecific;
viewSpecific = aSummary.className.match(/(splitview\-[\w-]+)/g); viewSpecific = aSummary.className.match(/(splitview\-[\w-]+)/g);

View File

@ -127,11 +127,10 @@ this.log = function log()
* Selector string or DOMElement for the element(s) to wire up. * Selector string or DOMElement for the element(s) to wire up.
* @param object aDescriptor * @param object aDescriptor
* An object describing how to wire matching selector, supported properties * An object describing how to wire matching selector, supported properties
* are "events", "attributes" and "userData" taking objects themselves. * are "events" and "attributes" taking objects themselves.
* Each key of properties above represents the name of the event, attribute * Each key of properties above represents the name of the event or
* or userData, with the value being a function used as an event handler, * attribute, with the value being a function used as an event handler or
* string to use as attribute value, or object to use as named userData * string to use as attribute value.
* respectively.
* If aDescriptor is a function, the argument is equivalent to : * If aDescriptor is a function, the argument is equivalent to :
* {events: {'click': aDescriptor}} * {events: {'click': aDescriptor}}
*/ */
@ -157,7 +156,6 @@ this.wire = function wire(aRoot, aSelectorOrElement, aDescriptor)
element.addEventListener(aName, aHandler, false); element.addEventListener(aName, aHandler, false);
}); });
forEach(aDescriptor.attributes, element.setAttribute); forEach(aDescriptor.attributes, element.setAttribute);
forEach(aDescriptor.userData, element.setUserData);
} }
} }