This repository was archived by the owner on Jun 12, 2026. It is now read-only.
eo-translatorjs v3.1.3
π Bug Fixes
translateDOMoperator precedence β the container argument was silently ignored; the method always fell back todocumentregardless of what was passed. Fixed with??null-coalescing.translate()used wrong variable for language lookup β whenoptions.langwas supplied thehasOwnPropertyguard still checkedthis.language, causing incorrect fallback behaviour.- Error messages printed
"string"instead of the actual key β language error messages interpolatedtypeof lang(always"string") rather than the key value itself. add()nested traversal was fragile β the embeddedtempDict[frag] = {}assignment inside a||expression could silently fail and the final key was set inside the loop instead of after it. Rewritten as a cleanforloop.extractValueused truthiness β falsy-but-valid translation values (0,false,"") were treated as missing. Changed to an explicit== nullguard.translateElementaccessed.valuewithout null-checking β reading.attributes["eo-translator"].valuewithout first verifying the attribute existed could throw. All optional attribute reads are now null-guarded; passingnullis a safe no-op.
π Security & Safety
assignParamsRegExp injection β parameter key names are now escaped withkey.replace(/[$()*+.?[]^{|}]/g, "\\$&")before being used in aRegExpconstructor, preventing injection from keys that contain regex special characters.
β»οΈ Refactoring
- Replaced all
obj.hasOwnProperty(key)calls withObject.prototype.hasOwnProperty.call(obj, key)to eliminateno-prototype-builtinsviolations. translateDOMnow correctly usesDOMContainer ?? (typeof document === "object" ? document : null).- Error type distinction: validation errors on wrong types now throw
TypeError; missing key errors throwError. - Removed dead
dict || {}fallback in constructor (the preceding guard already ensuresdictis truthy). - Fixed typos:
"recieved"β"received","transition"β"translation"in comments and error messages.
π§ͺ Tests
- Test count: 22 β 44 (+22).
- Error-path tests migrated from
try/catch + boolean flagtoexpect(() => β¦).toThrow()with message and type assertions. - New coverage:
languagesgetter,isValidLanguage(), dictionary/language setters (valid & invalid),translate()withlangoverride, fallback option, language not found, multiple params, deeply nested keys,translateElementHTML rendering (eo-translator-html="true/false"),translateElement(null)no-op,translateDOM()on container,translateDOM()with language override.
π§ Tooling & Infrastructure
- Migrated from npm β pnpm (
pnpm-lock.yaml,pnpm-workspace.yaml). - Added ESLint via
@eoussama/dx(eslint.config.js):pnpm lint/pnpm run lint:fix. - All 19 audit vulnerabilities resolved β
pnpm auditreports 0 vulnerabilities (combination of direct dependency upgrades andpnpm-workspace.yamloverrides). - Removed
package-lock.json.
π Documentation
- README fully rewritten: installation (npm/pnpm/yarn + CDN), Node.js/CommonJS usage, full API reference with parameter tables and runnable examples for every method (
translate,translateElement,translateDOM,add,remove,isValidLanguage,languagesgetter,dictionaryandlanguageproperties).
π·οΈ Rename
- Project renamed from
translatorjstoeo-translatorjsthroughout: package name, source file (src/eo-translatorjs.js), test file (tests/eo-translatorjs.test.js), type declarations (types/eo-translatorjs.d.ts), dist output, error message prefixes ([EOTranslatorJS]), and all URLs/docs.
Full Changelog: v3.1.1...3.1.3