Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes the check for custom-template declaration #13165

Merged
merged 2 commits into from Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/service/template-impl.js
Expand Up @@ -289,7 +289,6 @@ export class Templates {
return this.templateClassMap_[type];
}

this.checkTemplateDeclared_(element, type);
let aResolve;
const promise = new Promise((resolve, unusedReject) => {
aResolve = resolve;
Expand All @@ -299,29 +298,6 @@ export class Templates {
return promise;
}


/**
* Checks that the template type has actually been declared by a
* `<script custom-template=$type>` tag in the head.
* @param {!Element} element
* @param {string} type
* @private
*/
checkTemplateDeclared_(element, type) {
if (!this.declaredTemplates_) {
this.declaredTemplates_ = this.win_.Object.create(null);
const scriptTags = this.win_.document.querySelectorAll(
'script[custom-template]');
for (let i = 0; i < scriptTags.length; i++) {
this.declaredTemplates_[scriptTags[i].getAttribute(
'custom-template')] = true;
}
}
user().assert(this.declaredTemplates_[type],
'Template must be declared for %s as <script custom-template=%s>',
element, type);
}

/**
* Registers an extended template. This function should typically be called
* through the registerTemplate method on the AMP runtime.
Expand Down
7 changes: 0 additions & 7 deletions test/functional/test-template.js
Expand Up @@ -87,13 +87,6 @@ describes.fakeWin('Template', {}, env => {
}).to.throw(/Duplicate template type/);
});

it('should fail render if template is not declared', () => {
const templateElement = createTemplateElement();
expect(() => {
templates.renderTemplate(templateElement, {value: 0});
}).to.throw(/Template must be declared/);
});

it('should block render until template registered', () => {
templates.declaredTemplates_ = undefined;
const templateElement = createTemplateElement();
Expand Down