Mathijs den Burger pushed to branch feature/cmng-psp1 at cms-community / hippo-addon-channel-manager
Commits: 27c98f1f by Canh Ngo at 2016-05-24T09:51:17+02:00 CHANNELMGR-666 ignored parsing metadata if iframe's been unloaded - - - - - 173a0022 by Mathijs den Burger at 2016-05-25T17:13:26+02:00 CHANNELMGR-666 check if iframe dom is present after each async call - - - - - e1c9c09f by Mathijs den Burger at 2016-05-25T17:14:52+02:00 CHANNELMGR-666 Merge changes into mainline - - - - - 3 changed files: - frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js - frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js - frontend-ng/src/angularjs/channel/hippoIframe/hstCommentsProcessor.service.js Changes: ===================================== frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js +++ b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.js @@ -77,12 +77,16 @@ export class HippoIframeCtrl { onLoad() { // we insert the CSS for every page, because embedded links can come and go without reloading the page this._insertCss().then(() => { - this._parseHstComments(); - this._updateDragDrop(); - this._updateChannelIfSwitched().then(() => { - this._parseLinks(); - this.HippoIframeService.signalPageLoadCompleted(); - }); + if (this._isIframeDomPresent()) { + this._parseHstComments(); + this._updateDragDrop(); + this._updateChannelIfSwitched().then(() => { + if (this._isIframeDomPresent()) { + this._parseLinks(); + this.HippoIframeService.signalPageLoadCompleted(); + } + }); + } }); // TODO: handle error. // show dialog explaining that for this channel, the CM can currently not be used, @@ -142,7 +146,7 @@ export class HippoIframeCtrl { } _insertCss() { - const iframeWindow = this._getIframeDOM().defaultView; + const iframeWindow = this._getIframeDom().defaultView; const appRootUrl = this.DomService.getAppRootUrl(); const hippoIframeCss = `${appRootUrl}styles/hippo-iframe.css`; return this.DomService.addCss(iframeWindow, hippoIframeCss); @@ -151,7 +155,7 @@ export class HippoIframeCtrl { _parseHstComments() { this.PageStructureService.clearParsedElements(); this.hstCommentsProcessorService.run( - this._getIframeDOM(), + this._getIframeDom(), this.PageStructureService.registerParsedElement.bind(this.PageStructureService) ); this.PageStructureService.attachEmbeddedLinks(); @@ -166,12 +170,16 @@ export class HippoIframeCtrl { return this.$q.resolve(); } - _getIframeDOM() { + _isIframeDomPresent() { + return !!this._getIframeDom(); + } + + _getIframeDom() { return this.iframeJQueryElement.contents()[0]; } _parseLinks() { - const iframeDom = this._getIframeDOM(); + const iframeDom = this._getIframeDom(); const protocolAndHost = `${iframeDom.location.protocol}//${iframeDom.location.host}`; const internalLinkPrefixes = this.ChannelService.getPreviewPaths().map((path) => protocolAndHost + path); ===================================== frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js +++ b/frontend-ng/src/angularjs/channel/hippoIframe/hippoIframe.controller.spec.js @@ -81,7 +81,7 @@ describe('hippoIframeCtrl', () => { scope.$digest(); hippoIframeCtrl = el.controller('hippo-iframe'); - spyOn(hippoIframeCtrl, '_getIframeDOM').and.returnValue(iframeDom); + spyOn(hippoIframeCtrl, '_getIframeDom').and.returnValue(iframeDom); }); it('unsubscribes "delete-component" event when the scope is destroyed', () => { ===================================== frontend-ng/src/angularjs/channel/hippoIframe/hstCommentsProcessor.service.js ===================================== --- a/frontend-ng/src/angularjs/channel/hippoIframe/hstCommentsProcessor.service.js +++ b/frontend-ng/src/angularjs/channel/hippoIframe/hstCommentsProcessor.service.js @@ -28,7 +28,7 @@ export class HstCommentsProcessorService { run(document, callback) { if (!document) { - return; + throw new Error('DOM document is empty'); } // IE doesn't support 'evaluate', see // https://developer.mozilla.org/en/docs/Web/API/Document/evaluate#Browser_compatibility View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/e5ede7af159d3c98c876b19fc6858a193e8d0690...e1c9c09f02939a3b028349741c04a54994bc9279
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn