WIP switch to webcomponents loader async polyfills; multiple small fixes for Firefox and generally more defensive coding

This commit is contained in:
Ludwig Schubert
2017-10-24 16:48:48 -07:00
parent 11b00b4cee
commit f388c39553
7 changed files with 165 additions and 129 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { Template } from '../mixins/template';
// import { Template } from '../mixins/template';
import { Controller } from '../controller';
const isOnlyWhitespace = /^\s*$/;
@@ -31,7 +31,7 @@ export class Article extends HTMLElement {
connectedCallback() {
document.onreadystatechange = function () {
console.log("onreadystatechange:");
console.log('onreadystatechange:');
console.log(document.readyState);
};
console.info('Article tag connected, we can now listen to controller events.');
+6
View File
@@ -35,6 +35,12 @@ export class Bibliography extends HTMLElement {
observer.observe(this, options);
}
connectedCallback() {
requestAnimationFrame(() => {
this.parseIfPossible();
});
}
parseIfPossible() {
const scriptTag = this.querySelector('script');
if (!scriptTag) return;
+6 -8
View File
@@ -49,12 +49,6 @@ export class Cite extends T(HTMLElement) {
/* Lifecycle */
// constructor() {
// super();
// // Cite.currentId += 1;
// // this.citeId = Cite.currentId;
// }
connectedCallback() {
this.outerSpan = this.root.querySelector('#citation-');
this.innerSpan = this.root.querySelector('.citation-number');
@@ -105,11 +99,15 @@ export class Cite extends T(HTMLElement) {
return index == -1 ? '?' : index + 1 + '';
});
const textContent = '[' + numberStrings.join(', ') + ']';
this.innerSpan.textContent = textContent;
if (this.innerSpan) {
this.innerSpan.textContent = textContent;
}
}
set entries(entries) {
this.hoverBox.innerHTML = entries.map(hover_cite).join('<br><br>');
if (this.hoverBox) {
this.hoverBox.innerHTML = entries.map(hover_cite).join('<br><br>');
}
}
}