зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1019643 - use Cu.cloneInto for browser elements instead of manually looping through objects and exposing them, r=bholley
--HG-- extra : transplant_source : %D4%CDG%19-%27F%C4%93%D5LF%2CE%0B%F7%2A6%94%E9
This commit is contained in:
Родитель
1e9b9fba77
Коммит
adfd373291
|
@ -40,26 +40,6 @@ function getIntPref(prefName, def) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function exposeAll(obj) {
|
|
||||||
// Filter for Objects and Arrays.
|
|
||||||
if (typeof obj !== "object" || !obj)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Recursively expose our children.
|
|
||||||
Object.keys(obj).forEach(function(key) {
|
|
||||||
exposeAll(obj[key]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// If we're not an Array, generate an __exposedProps__ object for ourselves.
|
|
||||||
if (obj instanceof Array)
|
|
||||||
return;
|
|
||||||
var exposed = {};
|
|
||||||
Object.keys(obj).forEach(function(key) {
|
|
||||||
exposed[key] = 'rw';
|
|
||||||
});
|
|
||||||
obj.__exposedProps__ = exposed;
|
|
||||||
}
|
|
||||||
|
|
||||||
function defineAndExpose(obj, name, value) {
|
function defineAndExpose(obj, name, value) {
|
||||||
obj[name] = value;
|
obj[name] = value;
|
||||||
if (!('__exposedProps__' in obj))
|
if (!('__exposedProps__' in obj))
|
||||||
|
@ -499,7 +479,7 @@ BrowserElementParent.prototype = {
|
||||||
// This will have to change if we ever want to send a CustomEvent with null
|
// This will have to change if we ever want to send a CustomEvent with null
|
||||||
// detail. For now, it's OK.
|
// detail. For now, it's OK.
|
||||||
if (detail !== undefined && detail !== null) {
|
if (detail !== undefined && detail !== null) {
|
||||||
exposeAll(detail);
|
detail = Cu.cloneInto(detail, this._window);
|
||||||
return new this._window.CustomEvent('mozbrowser' + evtName,
|
return new this._window.CustomEvent('mozbrowser' + evtName,
|
||||||
{ bubbles: true,
|
{ bubbles: true,
|
||||||
cancelable: cancelable,
|
cancelable: cancelable,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче