Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverted some changes
  • Loading branch information
mszylkowski committed Oct 18, 2021
commit 0a6f0d42fa40c7b27c9b71a60ba198bd173077a1
35 changes: 11 additions & 24 deletions extensions/amp-story-dev-tools/0.1/amp-story-dev-tools-tab-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {htmlFor} from '#core/dom/static-template';

import {Services} from '#service';

import {user, userAssert} from '#utils/log';
import {userAssert} from '#utils/log';

import {urls} from '../../../src/config';
import {loadScript} from '../../../src/validator-integration';
Expand Down Expand Up @@ -67,9 +67,6 @@ const buildLogMessageTemplate = (element) => {
</div>`;
};

/** @const {string} */
const TAG = 'AMP_STORY_DEV_TOOLS_DEBUG';

export class AmpStoryDevToolsTabDebug extends AMP.BaseElement {
/** @override @nocollapse */
static prerenderAllowed() {
Expand All @@ -96,26 +93,11 @@ export class AmpStoryDevToolsTabDebug extends AMP.BaseElement {
buildCallback() {
this.storyUrl_ = this.element.getAttribute('data-story-url');
this.element.classList.add('i-amphtml-story-dev-tools-tab');
return this.tryValidatingDocument_();
}

/** @override */
layoutCallback() {
return this.tryValidatingDocument_().finally(() =>
this.buildDebugContent_()
);
}

/**
* Attempts to load the validator, fetch the document and run the validator.
* Can reject due to network conditions or validator initialization.
* @return {!Promise}
*/
tryValidatingDocument_() {
if (this.errorList_ != null) {
return Promise.resolve();
}
return loadScript(this.element.ownerDocument, `${urls.cdn}/v0/validator.js`)
return loadScript(
this.element.ownerDocument,
`${urls.cdn}/v0/validator_wasm.js`
)
.then(() => amp.validator.init())
.then(() =>
this.validateUrl_(/* global amp: false */ amp.validator, this.storyUrl_)
)
Expand All @@ -126,6 +108,11 @@ export class AmpStoryDevToolsTabDebug extends AMP.BaseElement {
.catch(() => {});
}

/** @override */
layoutCallback() {
this.buildDebugContent_();
}

/**
* Validates a URL input, showing the errors on the screen.
*
Expand Down