Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw _this.component.createError('Can not attach multiple components to the same window');
}
_this.component = component;
_this.onPropHandlers = [];
var _parseChildWindowName = parseChildWindowName(),
parent = _parseChildWindowName.parent,
domain = _parseChildWindowName.domain,
exports = _parseChildWindowName.exports,
context = _parseChildWindowName.context,
props = _parseChildWindowName.props;
_this.context = context;
_this.parentComponentWindow = _this.getWindowByRef(parent);
_this.parentExports = deserializeMessage(_this.parentComponentWindow, domain, exports);
_this.checkParentDomain(domain);
window.xchild = _this.component.xchild = _this;
var initialProps = _this.getPropsByRef(_this.parentComponentWindow, domain, props);
_this.setProps(initialProps, domain);
markWindowKnown(_this.parentComponentWindow);
_this.watchForClose();
return _this.parentExports.init(_this.buildExports());
}).then(function () {
return _this.watchForResize();
const childPayload = getChildPayload();
if (!childPayload) {
throw new Error(`No child payload found`);
}
if (childPayload.version !== __ZOID__.__VERSION__) {
throw new Error(`Parent window has zoid version ${ childPayload.version }, child window has version ${ __ZOID__.__VERSION__ }`);
}
const { parent, parentDomain, exports, context, props } = childPayload;
this.context = context;
this.parentComponentWindow = this.getParentComponentWindow(parent);
this.parentDomain = parentDomain;
this.parent = deserializeMessage(this.parentComponentWindow, parentDomain, exports);
this.checkParentDomain(parentDomain);
const initialProps = this.getPropsByRef(this.parentComponentWindow, parentDomain, props);
this.setProps(initialProps, parentDomain);
markWindowKnown(this.parentComponentWindow);
this.watchForClose();
return this.parent.init(this.buildExports());
}).then(() => {
return this.watchForResize();
}
var global = globalFor(parentComponentWindow);
if (!global) {
throw new Error('Can not find global for parent component - can not retrieve props');
}
props = global.props[uid];
}
if (!props) {
throw new Error('Initial props not found');
}
return deserializeMessage(parentComponentWindow, domain, props);
};
if (type === INITIAL_PROPS.RAW) {
props = value;
} else if (type === INITIAL_PROPS.UID) {
if (!isSameDomain(parentComponentWindow)) {
throw new Error(`Parent component window is on a different domain - expected ${ getDomain() } - can not retrieve props`);
}
const global = getGlobal(parentComponentWindow);
props = assertExists('props', global && global.props[uid]);
}
if (!props) {
throw new Error(`Could not find props`);
}
return deserializeMessage(parentComponentWindow, domain, props);
}