Skip to content

Commit

Permalink
Change to use this-only instead of local
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelWest22 authored Dec 5, 2024
1 parent a486cd7 commit 3834d26
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4928,9 +4928,9 @@ var htmx = (function() {
extensionsToIgnore.push(extensionName.slice(7))
return
}
if (extensionName.indexOf('local:') === 0) {
if (extensionName.indexOf('this-only:') === 0) {
if (isParentScan) return
extensionName = extensionName.slice(6)
extensionName = extensionName.slice(10)
}
if (extensionsToIgnore.indexOf(extensionName) < 0) {
const extension = extensions[extensionName]
Expand Down
4 changes: 2 additions & 2 deletions test/attributes/hx-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ describe('hx-ext attribute', function() {
ext5Calls.should.equal(1)
})

it('Extensions can be local properly', function() {
it('Extensions can be applied to this element only properly', function() {
this.server.respondWith('GET', '/test', 'Clicked!')

make('<div id="div-AA" hx-ext="local:ext-1,ext-2,ext-5" hx-get="/test" foo="foo" hx-trigger="click">Click Me!' +
make('<div id="div-AA" hx-ext="this-only:ext-1,ext-2,ext-5" hx-get="/test" foo="foo" hx-trigger="click">Click Me!' +
'<div id="div-BB" hx-ext="ignore:ext-5"><button id="btn-BB" hx-get="/test" foo="foo" hx-trigger="click consume"></button></div></div>')

var div1 = byId('div-AA')
Expand Down
4 changes: 2 additions & 2 deletions www/content/attributes/hx-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ hierarchy and it will apply to all child elements.
</div>
```

* If an extension needs to apply only to a single element you can override inheritance on an element using `hx-ext="local:extensionName"`
* If an extension needs to apply only to a single element you can override inheritance on an element using `hx-ext="this-only:extensionName"`

```html
<div hx-ext="local:example"> <!-- "Example" extension is used just on this element -->
<div hx-ext="this-only:example"> <!-- "Example" extension is used just on this element only -->
<div>
... but it will not be used in this part.
</div>
Expand Down

0 comments on commit 3834d26

Please sign in to comment.