From 5e9e23fa6849ca88a5229c40a1c9c0412f987071 Mon Sep 17 00:00:00 2001 From: Terry Aney Date: Mon, 31 Oct 2022 20:18:09 -0500 Subject: [PATCH 1/5] processDirective correctly removing attribute names with 'modifiers' --- src/walk.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/walk.ts b/src/walk.ts index f996461..708c391 100644 --- a/src/walk.ts +++ b/src/walk.ts @@ -121,6 +121,7 @@ const processDirective = ( let dir: Directive let arg: string | undefined let modifiers: Record | undefined + const attrName = raw; // modifiers raw = raw.replace(modifierRE, (_, m) => { @@ -143,7 +144,7 @@ const processDirective = ( if (dir) { if (dir === bind && arg === 'ref') dir = ref applyDirective(el, dir, exp, ctx, arg, modifiers) - el.removeAttribute(raw) + el.removeAttribute(attrName) } else if (import.meta.env.DEV) { console.error(`unknown custom directive ${raw}.`) } From 05bae19bf606e4cf21c51fea5809cbe629d19e75 Mon Sep 17 00:00:00 2001 From: Terry Aney Date: Mon, 12 Dec 2022 05:51:51 -0600 Subject: [PATCH 2/5] Made bind.ts force the 'onclick' binding to an attribute --- src/directives/bind.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/directives/bind.ts b/src/directives/bind.ts index 814c882..ceb85e3 100644 --- a/src/directives/bind.ts +++ b/src/directives/bind.ts @@ -8,7 +8,7 @@ import { camelize } from '@vue/shared' -const forceAttrRE = /^(spellcheck|draggable|form|list|type)$/ +const forceAttrRE = /^(spellcheck|draggable|form|list|type|onclick)$/ export const bind: Directive = ({ el, From dd9ebaa78dfe49fa383239fe7b3cec6e4162e1f5 Mon Sep 17 00:00:00 2001 From: Terry Aney Date: Wed, 22 Mar 2023 12:11:52 -0500 Subject: [PATCH 3/5] Cactch error in block.remove when parentNode is null --- src/block.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/block.ts b/src/block.ts index 95cb2cb..927912c 100644 --- a/src/block.ts +++ b/src/block.ts @@ -80,8 +80,19 @@ export class Block { if (node === this.end) break node = next } - } else { - this.template.parentNode!.removeChild(this.template) + } else { + try { + // Possibly related to https://github.com/vuejs/petite-vue/discussions/188 , but at times (not always predictable, so not + // sure what markup/order causes issue) a simple v-for="o in model.searchResultsResources" would cause an error when reactivity + // was changing for searchResultsResources from an array with values to an empty array, parentNode was occasionally null. + if (this.template.isConnected) { + this.template.parentNode!.removeChild(this.template) + } + } catch (error) { + console.log("petite-vue: Unable to remove template"); + console.log(error); + console.log(this.template); + } } this.teardown() } From 1a1b89adbf6e408c83670100c20d4fccbdecdefa Mon Sep 17 00:00:00 2001 From: Terry Aney Date: Sat, 1 Apr 2023 13:56:52 -0500 Subject: [PATCH 4/5] Reformatted my Block.ts commit to use spaces instead of tabs to match project --- src/block.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/block.ts b/src/block.ts index 927912c..123cb12 100644 --- a/src/block.ts +++ b/src/block.ts @@ -80,19 +80,19 @@ export class Block { if (node === this.end) break node = next } - } else { - try { - // Possibly related to https://github.com/vuejs/petite-vue/discussions/188 , but at times (not always predictable, so not - // sure what markup/order causes issue) a simple v-for="o in model.searchResultsResources" would cause an error when reactivity - // was changing for searchResultsResources from an array with values to an empty array, parentNode was occasionally null. - if (this.template.isConnected) { - this.template.parentNode!.removeChild(this.template) - } - } catch (error) { - console.log("petite-vue: Unable to remove template"); - console.log(error); - console.log(this.template); - } + } else { + try { + // Possibly related to https://github.com/vuejs/petite-vue/discussions/188 , but at times (not always predictable, so not + // sure what markup/order causes issue) a simple v-for="o in model.searchResultsResources" would cause an error when reactivity + // was changing for searchResultsResources from an array with values to an empty array, parentNode was occasionally null. + if (this.template.isConnected) { + this.template.parentNode!.removeChild(this.template) + } + } catch (error) { + console.log("petite-vue: Unable to remove template"); + console.log(error); + console.log(this.template); + } } this.teardown() } From c7c37198c5f3bb577a7714cf6a9105bac0a867bf Mon Sep 17 00:00:00 2001 From: Terry Aney Date: Mon, 22 Jan 2024 10:49:58 -0600 Subject: [PATCH 5/5] Retaining class values with v-bind="{ class: }" usage --- src/directives/bind.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/directives/bind.ts b/src/directives/bind.ts index ceb85e3..b444897 100644 --- a/src/directives/bind.ts +++ b/src/directives/bind.ts @@ -20,7 +20,8 @@ export const bind: Directive = ({ let prevValue: any // record static class - if (arg === 'class') { + // Update: Was checking if arg==="class", but that was false if bind to { class: }, so just storing no matter what for later use + if (el.className) { el._class = el.className }