@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
@@ -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}
|
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("
|
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
|
|
package/source/types/version.mjs
CHANGED
package/test/cases/monster.mjs
CHANGED