Skip to content

Commit

Permalink
Removes the check for custom-template declaration (ampproject#13165)
Browse files Browse the repository at this point in the history
* Removes the check for custom-template declaration

* remove test
  • Loading branch information
lannka authored and protonate committed Mar 15, 2018
1 parent f5d6c1f commit 4ce0846
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
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

0 comments on commit 4ce0846

Please sign in to comment.