Code Monkey home page Code Monkey logo

Comments (4)

thomashandorf avatar thomashandorf commented on May 26, 2024

Thanks for reporting! Makes sense. We should should add in router.js -> $.addDelegtedListener(function()) a check to the if clause: if a target is given and the target is not "_self", navigate shouldn't be called and default should not be prevented

from layerjs.

netaisllc avatar netaisllc commented on May 26, 2024

Such as...

/*
 * Issue #75 :: Anchor tag attribute target="{my value}" seems to be ignored
 * as at 9-May-2018
 * 
 * Spec :: We should should add in router.js -> $.addDelegtedListener(function()) a check to the if clause:
 *    if 
 *      a target is given AND the target is not "_self", 
 *    then
 *      navigate shouldn't be called AND default should not be prevented
 **/

// register link listener
$.addDelegtedListener(this.rootElement, 'click', 'a:not([data-lj-nolink=\'true\']):not([lj-nolink=\'true\'])', function(event) {
    //delete that.ignoreUrl;
    
    var _navigationHandler = function(result) {
      if (!result) {
        setTimeout(function() { // why do we have to get at the end of the queue?
            that.ignoreUrl = $.getAbsoluteUrl(href);
            window.location.href = href;
        }, 1);
      }
    }

    if (this.href !== '' && !this.href.startsWith('javascript:')) { // jshint ignore:line
      // get the explicitly given href (that is not extended) to see the intention of the user
      var href = this.getAttribute('href');

      // check for target attr
      var tget = this.getAttribute('target');
      // if target is != '_self', honor it as user intention
      if( tget && tget !== '_self' ) {
        return
      }
      else {

        event.preventDefault(); // prevent default action, i.e. going to link target
        // do not stop propagation; other libraries may listen to link clicks
        that.navigate(href, $.findParentViewOfType(this, 'layer')).then( _navigationHandler );
      }    
    }
});

Would you like a PR?

from layerjs.

thomashandorf avatar thomashandorf commented on May 26, 2024

@netaisllc yes please, submit a PR (:

from layerjs.

thomashandorf avatar thomashandorf commented on May 26, 2024

fixed in 4533a9d

from layerjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.