Skip to content

Commit 654b623

Browse files
committed
fix: change init function to default export and update parameter handling
1 parent 1167070 commit 654b623

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const cssMarker = typeof document !== 'undefined' ? document.querySelector('link
180180
* Processes one or more elements to attach plugins.
181181
* @param {HTMLElement|NodeList|Array} elements - Element, or Collection of Elements
182182
*/
183-
export function init(elements) {
183+
function init(elements) {
184184
if (!elements) return;
185185

186186
let collection = [];
@@ -351,10 +351,10 @@ function executeGenericPlugin(el, name) {
351351
* - $anime.stagger(100)
352352
*/
353353
function processParams(el, params) {
354-
if (typeof params === 'string' && params.startsWith('$')) {
354+
if (typeof params === 'string' && params.startsWith('\u0024')) {
355355
try {
356356
// 1. Check for Method Call: $root.path.to.func(arg)
357-
const callMatch = params.match(/^\$([^.]+)\.(.+)\((.*)\)$/);
357+
const callMatch = params.match(/^\u0024([^.]+)\.(.+)\((.*)\)$/);
358358
if (callMatch) {
359359
const [_, root, path, arg] = callMatch;
360360
const obj = (root === 'this') ? el : window[root];
@@ -371,7 +371,7 @@ function processParams(el, params) {
371371
}
372372

373373
// 2. Check for Property Access: $root.path.to.prop or just $root
374-
const propMatch = params.match(/^\$([^.]+)(?:\.(.+))?$/);
374+
const propMatch = params.match(/^\u0024([^.]+)(?:\.(.+))?$/);
375375
if (propMatch) {
376376
const [_, root, path] = propMatch;
377377
const obj = (root === 'this') ? el : window[root];
@@ -410,4 +410,6 @@ Observer.init({
410410
// Auto-init for existing elements
411411
if (typeof document !== 'undefined') {
412412
init(document.querySelectorAll("[plugin]"));
413-
}
413+
}
414+
415+
export default { init }

0 commit comments

Comments
 (0)