Open MichaelWest22 opened 1 week ago
Not a change request at all, just throwing out alternative naming ideas for the prefix itself in case you think they sound good ; self:
, isolate:
, or isolated:
came to mind while answering on the issue
Yeah local:
is not the perfect word for this but I've struggled to find a better word that fits as well. local brings to mind things like local vs global scope which is well understood but in a way the current extension default behavior is already locally scoped to the form element! it just also applies to the form elements children because they are in the same scope normally. But in this use case we want to just break inheritance to the children which makes self:
make more sense. isolate:
and isolated:
have the issue that is not obvious what you are isolating without reading the documentation as i think these are less self explaining than 'local:'.
What i like about local:
is that how it reads in your head when looking at hx-ext="local:my-exetnsion" as it makes you think "my-extension is a local extension that only applies locally". But something like self:
while possibly more accurate you have to think hx-ext="self:my-extension" means "my-extension is an extension that only applies to itself where itself refers to the local element it is tagged on".
There are other more complex options that are even more accurate and descriptive like disinherit:
(mirror hx-disinherit attribute) or noninheritable:
or nonheritable:
. But the disinherit one feels more like the ignore:
case and not for setting the extension up situation. The other two *heritable ones seem to be too long and complicated to use to me.
Description
Allow hx-ext extension inheritance to be disabled on an element with a new
local:
prefix instead of having to useignore:
on all children.It works by setting isParentScan to track when scanning parent nodes recursively and then ignoring recursive calls that have ignore: prefix. Otherwise it strips the ignore: prefix.
Also improved readability/performance/minification by: removing un-needed explicit undefined checks moving replace => trim moving slice => indexOf
Corresponding issue: #3016
Testing
Added test to confirm extension with local: prefix does not get inherited as expected.
Checklist
master
for website changes,dev
for source changes)npm run test
) and verified that it succeeded