Skip to content

Commit

Permalink
Use setting set via global Polymer object.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jul 18, 2018
1 parent 2a38d38 commit a6331a2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

constructor() {
super();
if (window.strictTemplatePolicy) {
if (Polymer.strictTemplatePolicy) {
throw new Error(`strictTemplatePolicy: dom-bind not allowed`);
}
this.root = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/elements/dom-module.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
register(id) {
id = id || this.id;
if (id) {
if (window.strictTemplatePolicy && findModule(id)) {
if (Polymer.strictTemplatePolicy && findModule(id)) {
modules[id] = lcModules[id.toLowerCase()] = null;
throw new Error(`strictTemplatePolicy: dom-module ${id} registered twice`);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
// finally fall back to `_template` in element's prototype.
this.prototype._template ||
null;
if (window.strictTemplatePolicy && !template) {
if (Polymer.strictTemplatePolicy && !template) {
throw new Error(`strictTemplatePolicy: expecting dom-module or null _template for ${this.is}`);
}
return template;
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
// template; call the super impl this way so that `this` points
// to the superclass.
Object.getPrototypeOf(/** @type {PolymerElementConstructor}*/ (this).prototype).constructor.template;
if (window.strictTemplatePolicy && this.is && !template) {
if (Polymer.strictTemplatePolicy && this.is && !template) {
throw new Error(`strictTemplatePolicy: expecting dom-module or null template for ${this.is}`);
}
this._template = template;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/templatize.html
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
* @suppress {invalidCasts}
*/
templatize(template, owner, options) {
if (window.strictTemplatePolicy && !owner._methodHost) {
if (Polymer.strictTemplatePolicy && !owner._methodHost) {
throw new Error('strictTemplatePolicy: template owner not trusted');
}
options = /** @type {!TemplatizeOptions} */(options || {});
Expand Down
4 changes: 3 additions & 1 deletion test/unit/strict-template-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<head>
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
window.strictTemplatePolicy = true;
Polymer = {
strictTemplatePolicy: true
};
// Errors thrown in custom element reactions are not thrown up
// the call stack to the dom methods that provoked them, so need
// to catch them here and prevent mocha from complaining about them
Expand Down

0 comments on commit a6331a2

Please sign in to comment.