Skip to content

Commit

Permalink
Accept x-data="true" as a synonym for x-data="" (#3339)
Browse files Browse the repository at this point in the history
As per #3337, some frameworks (like htm) convert `<div x-data … />` to `<div x-data="true" … />` whereas Alpine.js currently only accepts `<div x-data="" … />`. This patch (as per #3337 (reply in thread)), also makes it accept `x-data="true"` to mean data is `{}`.
  • Loading branch information
aral committed Jan 28, 2023
1 parent e69b8b5 commit 23d4147
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/alpinejs/src/directives/x-data.js
Expand Up @@ -21,7 +21,7 @@ directive('data', skipDuringClone((el, { expression }, { cleanup }) => {

let data = evaluate(el, expression, { scope: dataProviderContext })

if (data === undefined) data = {}
if (data === undefined || data === true) data = {}

injectMagics(data, el)

Expand Down

0 comments on commit 23d4147

Please sign in to comment.