Skip to content

Commit 2c9e9dd

Browse files
committed
maint(core registry): Support class based pattern initialization.
1 parent 5933a35 commit 2c9e9dd

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/core/registry.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,24 @@ const registry = {
110110
*/
111111
const $el = $(el);
112112
const pattern = registry.patterns[name];
113-
if (pattern.init) {
114-
const plog = logging.getLogger(`pat.${name}`);
115-
if ($el.is(pattern.trigger)) {
116-
plog.debug("Initialising.", $el);
117-
try {
113+
const plog = logging.getLogger(`pat.${name}`);
114+
if (el.matches(pattern.trigger)) {
115+
plog.debug("Initialising.", el);
116+
try {
117+
if (pattern.init) {
118+
// old style initialisation
118119
pattern.init($el, null, trigger);
119-
plog.debug("done.");
120-
} catch (e) {
121-
if (dont_catch) {
122-
throw e;
123-
}
124-
plog.error("Caught error:", e);
120+
} else {
121+
// class based pattern initialisation
122+
new pattern($el, null, trigger);
123+
}
124+
125+
plog.debug("done.");
126+
} catch (e) {
127+
if (dont_catch) {
128+
throw e;
125129
}
130+
plog.error("Caught error:", e);
126131
}
127132
}
128133
},

0 commit comments

Comments
 (0)