diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c91432..38afdb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Put your changes here... +## 0.6.18 + +- Fixed a bug which caused client-side Teddy to rename yet more form elements accidentally. + ## 0.6.17 - Fixed a bug which caused client-side Teddy to handle array length lookups differently from `cheerio`-driven Teddy. diff --git a/package-lock.json b/package-lock.json index e2f18ea..891912c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "teddy", - "version": "0.6.17", + "version": "0.6.18", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "teddy", - "version": "0.6.17", + "version": "0.6.18", "license": "CC-BY-4.0", "dependencies": { "cheerio": "1.0.0" @@ -1825,9 +1825,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.60", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.60.tgz", - "integrity": "sha512-HcraRUkTKJ+8yA3b10i9qvhUlPBRDlKjn1XGek1zDGVfAKcvi8TsUnImGqLiEm9j6ZulxXIWWIo9BmbkbCTGgA==", + "version": "1.5.61", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.61.tgz", + "integrity": "sha512-CcRGSBCBB6L9c3PBJWYYrBo6Bzeoi+GZTKvtuRtooJGWsINk+mOInZWcssU35zDTAwreVcrMimc9aMyPpehRNw==", "dev": true, "license": "ISC" }, diff --git a/package.json b/package.json index e80c83d..02e124a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/rooseveltframework/teddy/graphs/contributors" } ], - "version": "0.6.17", + "version": "0.6.18", "files": [ "dist" ], diff --git a/teddy.js b/teddy.js index 9659b7d..e8d143d 100644 --- a/teddy.js +++ b/teddy.js @@ -164,7 +164,7 @@ function parseIncludes (dom, model, dynamic) { while (!foundBody) { let parentName if (!parent) parentName = 'body' - else parentName = parent.name || parent.nodeName?.toLowerCase() + else parentName = parent.nodeName?.toLowerCase() || parent.name if (parentName === 'noparse' || parentName === 'noteddy') { next = true break @@ -187,8 +187,8 @@ function parseIncludes (dom, model, dynamic) { const contents = templates[src] const localModel = Object.assign({}, model) for (const arg of dom(el).children()) { - if (browser) arg.name = arg.nodeName?.toLowerCase() - if (arg.name === 'arg') { + const argName = browser ? arg.nodeName?.toLowerCase() : arg.name + if (argName === 'arg') { if (browser) arg.attribs = getAttribs(arg) const argval = Object.keys(arg.attribs)[0] getOrSetObjectByDotNotation(localModel, argval, dom(arg).html()) @@ -222,7 +222,7 @@ function parseConditionals (dom, model) { while (!foundBody) { let parentName if (!parent) parentName = 'body' - else parentName = parent.name || parent.nodeName?.toLowerCase() + else parentName = parent.nodeName?.toLowerCase() || parent.name if (parentName === 'loop' || parentName === 'noparse' || parentName === 'noteddy') { next = true break @@ -241,8 +241,8 @@ function parseConditionals (dom, model) { } // check if it's an if tag and not an unless tag let isIf = true - if (browser) el.name = el.nodeName?.toLowerCase() - if (el.name === 'unless') isIf = false + const elName = browser ? el.nodeName?.toLowerCase() : el.name + if (elName === 'unless') isIf = false // evaluate conditional const condResult = evaluateConditional(args, model) if ((isIf && condResult) || ((!isIf && !condResult))) { @@ -250,8 +250,8 @@ function parseConditionals (dom, model) { let nextSibling = el.nextSibling const removeStack = [] while (nextSibling) { - if (browser) nextSibling.name = nextSibling.nodeName?.toLowerCase() - switch (nextSibling.name) { + const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name + switch (nextSiblingName) { case 'elseif': case 'elseunless': case 'else': @@ -273,8 +273,8 @@ function parseConditionals (dom, model) { // true block is false; find the next elseif, elseunless, or else tag to evaluate let nextSibling = el.nextSibling while (nextSibling) { - if (browser) nextSibling.name = nextSibling.nodeName?.toLowerCase() - switch (nextSibling.name) { + const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name + switch (nextSiblingName) { case 'elseif': // get conditions args = [] @@ -291,8 +291,8 @@ function parseConditionals (dom, model) { nextSibling = el.nextSibling const removeStack = [] while (nextSibling) { - if (browser) nextSibling.name = nextSibling.nodeName?.toLowerCase() - switch (nextSibling.name) { + const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name + switch (nextSiblingName) { case 'elseif': case 'elseunless': case 'else': @@ -333,8 +333,8 @@ function parseConditionals (dom, model) { nextSibling = el.nextSibling const removeStack = [] while (nextSibling) { - if (browser) nextSibling.name = nextSibling.nodeName?.toLowerCase() - switch (nextSibling.name) { + const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name + switch (nextSiblingName) { case 'elseif': case 'elseunless': case 'else': @@ -493,7 +493,7 @@ function parseOneLineConditionals (dom, model) { while (!foundBody) { let parentName if (!parent) parentName = 'body' - else parentName = parent.name || parent.nodeName?.toLowerCase() + else parentName = parent.nodeName?.toLowerCase() || parent.name if (parentName === 'loop' || parentName === 'noparse' || parentName === 'noteddy') { next = true break