@schukai/monster 3.10.0 → 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.10.0",
3
+ "version": "3.10.1",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -190,10 +190,12 @@ class Translations extends Base {
190
190
  /**
191
191
  * Returns the translations for the current document.
192
192
  *
193
- * @param element
194
- * @returns {*}
195
- * @throws {Error} Element is not an HTMLElement
196
- * @throws {Error} Missing translations
193
+ * @param {HTMLElement|undefined} [element] - Element to search for translations. Default: element with objectlink @schukai/monster/i18n/translations@@link.
194
+ * @returns {Translations}
195
+ * @throws {Error} Element is not an HTMLElement.
196
+ * @throws {Error} Cannot find element with translations. Add a translations object to the document.
197
+ * @throws {Error} This element has no translations.
198
+ * @throws {Error} Missing translations.
197
199
  */
198
200
  function getDocumentTranslations(element) {
199
201
 
@@ -201,14 +203,17 @@ function getDocumentTranslations(element) {
201
203
 
202
204
  if (!(element instanceof HTMLElement)) {
203
205
  element = d.querySelector('['+ATTRIBUTE_OBJECTLINK+'~="' + translationsLinkSymbol.toString() + '"]');
206
+ if (element === null) {
207
+ throw new Error("Cannot find element with translations. Add a translations object to the document.");
208
+ }
204
209
  }
205
210
 
206
211
  if (!(element instanceof HTMLElement)) {
207
- throw new Error("Element is not an HTMLElement");
212
+ throw new Error("Element is not an HTMLElement.");
208
213
  }
209
214
 
210
215
  if (!hasObjectLink(element, translationsLinkSymbol)) {
211
- throw new Error("Missing translations");
216
+ throw new Error("This element has no translations.");
212
217
  }
213
218
 
214
219
  let obj = getLinkedObjects(element, translationsLinkSymbol);
@@ -219,7 +224,7 @@ function getDocumentTranslations(element) {
219
224
  }
220
225
  }
221
226
 
222
- throw new Error("Missing translations");
227
+ throw new Error("Missing translations.");
223
228
 
224
229
  }
225
230
 
@@ -142,7 +142,7 @@ function getMonsterVersion() {
142
142
  }
143
143
 
144
144
  /** don't touch, replaced by make with package.json version */
145
- monsterVersion = new Version("3.10.0");
145
+ monsterVersion = new Version("3.10.1");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.10.0")
10
+ monsterVersion = new Version("3.10.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13