Skip to content

Commit

Permalink
Merge pull request #707 from kethinov/0.6.18
Browse files Browse the repository at this point in the history
0.6.18
  • Loading branch information
kethinov authored Nov 15, 2024
2 parents 331f79e + 0fd1000 commit 98bada9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://github.com/rooseveltframework/teddy/graphs/contributors"
}
],
"version": "0.6.17",
"version": "0.6.18",
"files": [
"dist"
],
Expand Down
30 changes: 15 additions & 15 deletions teddy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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
Expand All @@ -241,17 +241,17 @@ 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))) {
// render the true block and discard the elseif, elseunless, and else blocks
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':
Expand All @@ -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 = []
Expand All @@ -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':
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98bada9

Please sign in to comment.