web: Avoid TypeError when instantiating polyfill (fix #607)

Co-authored-by: JustinCB <JustinCB@opmbx.org>
This commit is contained in:
Justin-CB 2020-05-20 15:42:54 -04:00 committed by GitHub
parent 1582584be8
commit cbc2f6a03a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 20 deletions

View File

@ -57,29 +57,37 @@ exports.RufflePlayer = class RufflePlayer extends HTMLElement {
} }
update_styles() { update_styles() {
for (var i = 0; i < this.dynamic_styles.sheet.rules.length; i += 1) { if (this.dynamic_styles.sheet) {
this.dynamic_styles.sheet.deleteRule(i); if (this.dynamic_styles.sheet.rules) {
} for (
var i = 0;
if (this.attributes.width) { i < this.dynamic_styles.sheet.rules.length;
let width = RufflePlayer.html_dimension_to_css_dimension( i++
this.attributes.width.value ) {
); this.dynamic_styles.sheet.deleteRule(i);
if (width !== null) { }
this.dynamic_styles.sheet.insertRule(
`:host { width: ${width}; }`
);
} }
}
if (this.attributes.height) { if (this.attributes.width) {
let height = RufflePlayer.html_dimension_to_css_dimension( let width = RufflePlayer.html_dimension_to_css_dimension(
this.attributes.height.value this.attributes.width.value
);
if (height !== null) {
this.dynamic_styles.sheet.insertRule(
`:host { height: ${height}; }`
); );
if (width !== null) {
this.dynamic_styles.sheet.insertRule(
`:host { width: ${width}; }`
);
}
}
if (this.attributes.height) {
let height = RufflePlayer.html_dimension_to_css_dimension(
this.attributes.height.value
);
if (height !== null) {
this.dynamic_styles.sheet.insertRule(
`:host { height: ${height}; }`
);
}
} }
} }
} }