From 9857c54f35a9cbacc3e1c9474609e836f3654dc9 Mon Sep 17 00:00:00 2001 From: Mohd Hafizuddin M Marzuki Date: Sat, 12 Aug 2023 15:45:24 +0800 Subject: [PATCH] Add ability to get registered data --- packages/alpinejs/src/datas.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/alpinejs/src/datas.js b/packages/alpinejs/src/datas.js index 9706581cb..19fcdaf83 100644 --- a/packages/alpinejs/src/datas.js +++ b/packages/alpinejs/src/datas.js @@ -1,7 +1,11 @@ let datas = {} -export function data(name, callback) { +export function data(name, callback = null) { + if (callback === null) { + return datas[name] + } + datas[name] = callback }