CETEIcean 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "CETEIcean",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "JavaScript library to load a TEI XML document and register it as HTML5 custom elements.",
5
5
  "main": "src/CETEI.js",
6
6
  "keywords": [
@@ -23,8 +23,8 @@
23
23
  "http-server": "^14.1.1",
24
24
  "onchange": "^6.1.1",
25
25
  "rollup": "^2.57.0",
26
- "rollup-plugin-terser": "1.0.1",
27
- "terser": "^3.17.0"
26
+ "rollup-plugin-terser": "^7.0.2",
27
+ "terser": "^5.14.2"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "rollup -c rollup.config.js",
package/src/CETEI.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import defaultBehaviors from './defaultBehaviors';
2
2
  import * as utilities from './utilities';
3
- import {addBehaviors, addBehavior, applyBehaviors, removeBehavior} from './behaviors';
3
+ import {addBehaviors, addBehavior, removeBehavior} from './behaviors';
4
4
  import {learnElementNames, learnCustomElementNames} from './dom';
5
5
 
6
6
  class CETEI {
@@ -10,7 +10,6 @@ class CETEI {
10
10
  // Bind methods
11
11
  this.addBehaviors = addBehaviors.bind(this);
12
12
  this.addBehavior = addBehavior.bind(this);
13
- this.applyBehaviors = applyBehaviors.bind(this);
14
13
  this.removeBehavior = removeBehavior.bind(this);
15
14
 
16
15
  // Bind selected utilities
@@ -438,6 +437,15 @@ template(str, elt) {
438
437
  return result;
439
438
  }
440
439
 
440
+ // Define or apply behaviors for the document
441
+ applyBehaviors() {
442
+ if (window.customElements) {
443
+ this.define.call(this, this.els);
444
+ } else {
445
+ this.fallback.call(this, this.els);
446
+ }
447
+ }
448
+
441
449
  /*
442
450
  Registers the list of elements provided with the browser.
443
451
  Called by makeHTML5(), but can be called independently if, for example,
@@ -446,7 +454,7 @@ template(str, elt) {
446
454
  define(names) {
447
455
  for (let name of names) {
448
456
  try {
449
- let fn = this.getHandler(this.behaviors, name);
457
+ const fn = this.getHandler(this.behaviors, name);
450
458
  window.customElements.define(this.tagName(name), class extends HTMLElement {
451
459
  constructor() {
452
460
  super();
@@ -472,7 +480,7 @@ define(names) {
472
480
  // When using the same CETEIcean instance for multiple TEI files, this error becomes very common.
473
481
  // It's muted by default unless the debug option is set.
474
482
  if (this.debug) {
475
- console.log(tagName(name) + " couldn't be registered or is already registered.");
483
+ console.log(this.tagName(name) + " couldn't be registered or is already registered.");
476
484
  console.log(error);
477
485
  }
478
486
  }
package/src/behaviors.js CHANGED
@@ -71,12 +71,3 @@ export function removeBehavior(ns, element) {
71
71
  }
72
72
  delete this.behaviors[`${p}:${element}`];
73
73
  }
74
-
75
- // Define or apply behaviors for the document
76
- export function applyBehaviors() {
77
- if (window.customElements) {
78
- this.define.call(this, this.els);
79
- } else {
80
- this.fallback.call(this, this.els);
81
- }
82
- }
@@ -75,7 +75,6 @@
75
75
  CETEIcean.getHTML5('https://raw.githubusercontent.com/textcreationpartnership/A00689/master/A00689.xml', function(data) {
76
76
  document.getElementById("TEI").innerHTML = "";
77
77
  document.getElementById("TEI").appendChild(data);
78
- CETEIcean.addStyle(document, data);
79
78
  // Fix combining abbreviation marker in Chrome
80
79
  if (!!window.chrome) {
81
80
  var gs = document.getElementsByTagName("tei-g");
@@ -1,31 +0,0 @@
1
- <html>
2
- <head>
3
- <meta charset="utf-8">
4
- <link rel="stylesheet" href="CETEIcean.css" media="screen" charset="utf-8">
5
- </head>
6
- <body>
7
- <div id="TEI"></div>
8
- <script src="../dist/CETEI.js"></script>
9
- <script>
10
-
11
- /* Testing the functions for registering elements. All these should work */
12
-
13
- // Repeated elements should be skipped
14
- var els = ["TEI", "TEI", "teiHeader"];
15
-
16
- var CETEIcean = new CETEI();
17
-
18
- if (document.registerElement) {
19
- CETEIcean.registerAll(els);
20
- if (document.createElement("tei-TEI") instanceof HTMLElement) {
21
- console.log("tei-TEI correctly registered without conflict");
22
- }
23
- }
24
- else {
25
- console.log("HTML CE not supported. Fallback used.")
26
- }
27
-
28
-
29
- </script>
30
- </body>
31
- </html>