Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a-template

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-template - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

18

lib/index.js

@@ -34,2 +34,3 @@ 'use strict';

this.atemplate = [];
this.events = [];
if (opt) {

@@ -82,2 +83,7 @@ Object.keys(opt).forEach(function (key) {

});
this.events.push({
element: ele,
selector: '[data-bind]',
event: bindType
});
}

@@ -116,4 +122,16 @@ }, {

});
this.events.push({
element: ele,
selector: dataAction,
event: bindType
});
}
}, {
key: 'removeTemplateEvents',
value: function removeTemplateEvents() {
this.events.forEach(function (event) {
(0, _util.off)(event.element, event.selector, event.event);
});
}
}, {
key: 'addTemplate',

@@ -120,0 +138,0 @@ value: function addTemplate(id, html) {

21

lib/util.js

@@ -30,7 +30,10 @@ 'use strict';

var listenerList = [];
var on = exports.on = function on(element, query, eventNames, fn) {
var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var events = eventNames.split(' ');
events.forEach(function (event) {
element.addEventListener(event, function (e) {
var target = e.target;
var listener = function listener(e) {
var delegateTarget = findAncestor(e.target, query);

@@ -41,4 +44,18 @@ if (delegateTarget) {

}
};
listenerList.push({ listener: listener, element: element, query: query, event: event, capture: capture });
element.addEventListener(event, listener, capture);
});
};
var off = exports.off = function off(element, query, eventNames) {
var events = eventNames.split(' ');
events.forEach(function (event) {
listenerList.forEach(function (item, index) {
if (item.element === element && item.query === query && item.event === event) {
element.removeEventListener(event, item.listener, item.capture);
listenerList.splice(index, 1);
}
});
});
};

2

package.json
{
"name": "a-template",
"version": "0.6.0",
"version": "0.6.1",
"author": "steelydylan",

@@ -5,0 +5,0 @@ "description": "Simple Template Engine",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc