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

local-links

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

local-links - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

15

local-links.js

@@ -26,2 +26,6 @@ function isHTMLElement(obj) {

function isSecondaryButton(event) {
return (typeof event === 'object') && ('button' in event) && event.button !== 0;
}
// [1] http://blogs.msdn.com/b/ieinternals/archive/2011/02/28/internet-explorer-window-location-pathname-missing-slash-and-host-has-port.aspx

@@ -41,2 +45,7 @@ // [2] https://github.com/substack/catch-links/blob/7aee219cdc2c845c78caad6070886a9380b90e4c/index.js#L13-L17

// Skip non-primary clicks
if (isSecondaryButton(event)) {
return null;
}
// If we have an anchor but its not an A tag

@@ -139,11 +148,11 @@ // try to find the closest one

// Functions to be used in exports. Defined here for alias purposes
function pathname () {
function pathname() {
return isLocal.apply(null, getEventAndAnchor.apply(null, arguments));
}
function hash () {
function hash() {
return isLocal.apply(null, getEventAndAnchor.apply(null, arguments).concat(true));
}
function active () {
function active() {
var args = Array.prototype.slice.call(arguments);

@@ -150,0 +159,0 @@ var last = args[args.length - 1];

2

package.json
{
"name": "local-links",
"description": "Determine cross-browser if an event or anchor element should be handled locally.",
"version": "1.3.0",
"version": "1.4.0",
"author": "Luke Karrys <luke@lukekarrys.com>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -20,2 +20,3 @@ var test = require('tape');

'<a id="local2" href="/local/page/1">Local2</a>',
'<a id="local3" href="/local/page/1">Local3</a>',
'<a id="local-search" href="/local/page/1?param=2">Search</a>',

@@ -37,4 +38,7 @@ '<a id="relative" href="page-2">Relative</a>',

function triggerClick(el, modified){
function triggerClick(el, modified, button){
var ev;
if (button === undefined) {
button = 0; /*left*/
}
if (document.createEvent) {

@@ -49,3 +53,3 @@ ev = document.createEvent("MouseEvent");

!!modified, false, false, false, /* modifier keys */
0 /*left*/,
button,
null

@@ -57,2 +61,3 @@ );

ev.ctrlKey = !!modified;
ev.button = button;
el.dispatchEvent('onclick', ev);

@@ -254,2 +259,23 @@ }

});
test('Ignores middle clicks', function (t) {
var local = $('local3');
var plan = 1;
var count = 0;
var end = function () {
count++;
if (count === plan) {
t.end();
}
};
t.plan(plan);
attachClick(local, function(event) {
event.preventDefault();
t.equal(localLinks.pathname(event), null, 'should ignore middle-button clicks');
});
triggerClick(local, false, 1);
});
});
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