Comparing version 0.8.4 to 0.8.5
{ | ||
"name": "material", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"description": "A lightweight implementation of Material Design Components for the web - ES6", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,4 @@ // based on the work of | ||
const type = ['mobile', 'tablet', 'desktop'] | ||
const television = ['googletv', 'viera', 'smarttv', 'internet.tv', 'netcast', 'nettv', 'appletv', 'boxee', 'kylo', 'roku', 'dlnadoc', 'pov_tv', 'hbbtv', 'ce-html'] | ||
const changeOrientationList = [] | ||
@@ -23,18 +25,2 @@ | ||
// Detectable television devices. | ||
const television = [ | ||
'googletv', | ||
'viera', | ||
'smarttv', | ||
'internet.tv', | ||
'netcast', | ||
'nettv', | ||
'appletv', | ||
'boxee', | ||
'kylo', | ||
'roku', | ||
'dlnadoc', | ||
'pov_tv', | ||
'hbbtv', | ||
'ce-html' | ||
] | ||
@@ -41,0 +27,0 @@ // Main functions |
@@ -5,3 +5,3 @@ import extract from './extract' | ||
const events = { | ||
eventHandlers: [], // Utiliser un tableau pour stocker les événements et les gestionnaires | ||
eventHandlers: {}, // Utiliser un tableau pour stocker les événements et les gestionnaires | ||
@@ -11,2 +11,8 @@ attach (eventsArray, context) { | ||
// Ensure each context has a unique UID | ||
const uid = context._uid || (context._uid = context.options.class + Math.random().toString(36).substr(2, 9)) | ||
// Initialize storage for this context if it doesn't already exist | ||
this.eventHandlers[uid] = this.eventHandlers[uid] || {} | ||
eventsArray.forEach(([eventDef, funcDef, option]) => { | ||
@@ -25,3 +31,2 @@ const e = extract.e(context, eventDef) | ||
const bound = last(keys.join('.'), context) | ||
let handler = null | ||
@@ -34,14 +39,13 @@ | ||
} else { | ||
// console.error(`Can't bind function for ${eventDef}`) | ||
return | ||
return // Cannot bind function for eventDef | ||
} | ||
if (handler && e && e.element && e.element.addEventListener) { | ||
e.element.addEventListener(e.name, handler, option) | ||
this.eventHandlers.push({ eventDef, element: e.element, handler }) | ||
} else if (e && e.element && e.element.on && handler) { | ||
e.element.on(e.name, handler) | ||
this.eventHandlers.push({ eventDef, element: e.element, handler }) | ||
} else { | ||
// console.error(`Can't attach ${eventDef}`) | ||
if (!this.eventHandlers[uid][eventDef]) { | ||
if (handler && e && e.element?.addEventListener) { | ||
e.element.addEventListener(e.name, handler, option) | ||
this.eventHandlers[uid][eventDef] = handler | ||
} else if (e && e.element?.on && handler) { | ||
e.element.on(e.name, handler) | ||
this.eventHandlers[uid][eventDef] = handler | ||
} | ||
} | ||
@@ -54,16 +58,22 @@ }) | ||
detach (eventsArray, context) { | ||
(eventsArray || []).forEach(([eventDef]) => { | ||
this.eventHandlers.forEach((handlerObj, index) => { | ||
if (handlerObj.eventDef === eventDef) { | ||
const { element, handler } = handlerObj | ||
if (element.removeEventListener) { | ||
element.removeEventListener(eventDef, handler) | ||
} else if (element.off) { | ||
element.off(eventDef, handler) | ||
} | ||
delete this.eventHandlers[index] | ||
} | ||
}) | ||
this.eventHandlers = this.eventHandlers.filter(Boolean) // Nettoyer les entrées supprimées | ||
}) | ||
const uid = context._uid | ||
if (!this.eventHandlers[uid]) return | ||
eventsArray.forEach(([eventDef, funcDef, option]) => { | ||
const e = extract.e(context, eventDef) | ||
const handler = this.eventHandlers[uid][eventDef] | ||
if (handler) { | ||
e.element.removeEventListener(e.name, handler) | ||
} else if (e.element.off) { | ||
e.element.off(e.name, handler) | ||
} | ||
delete this.eventHandlers[uid][eventDef] | ||
} | ||
) | ||
}, | ||
list (context) { | ||
const uid = context?._uid | ||
return uid ? this.eventHandlers[uid] || {} : this.eventHandlers | ||
} | ||
@@ -70,0 +80,0 @@ } |
@@ -69,3 +69,3 @@ import EventEmitter from './mixin/emitter' | ||
setup () { | ||
console.log('events.attach', this.options.events) | ||
// console.log('events.attach', this.options.events) | ||
events.attach(this.options.events, this) | ||
@@ -79,3 +79,3 @@ | ||
click (event) { | ||
console.log('click', event) | ||
// console.log('click', event) | ||
if (!event.target.dataset.switcher) return | ||
@@ -82,0 +82,0 @@ this.select(event.target) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
466078
10987