Giter VIP home page Giter VIP logo

Comments (9)

carhartl avatar carhartl commented on May 18, 2024

But isn't consistent with the jQuery style of overloading methods.

It also seems to be inconsistent in itself with how a cookie is written. If at all there should then be a addCookie function along with removeCookie.

from jquery-cookie.

FagnerMartinsBrack avatar FagnerMartinsBrack commented on May 18, 2024

I may disagree with you. See the following example:

$().attr("id", "myID")
$().removeAttr("id")

There is no $().addAttr

removeCookie is much more intuitive and follow jquery's style

from jquery-cookie.

FagnerMartinsBrack avatar FagnerMartinsBrack commented on May 18, 2024

@carhartl Did you thought about this? Seriously I think it is a very good feature and it does'nt add so many chars =(

from jquery-cookie.

carhartl avatar carhartl commented on May 18, 2024

Nearly convinced.

from jquery-cookie.

carhartl avatar carhartl commented on May 18, 2024
$.removeCookie = function(name, options) {
    $.cookie(name, null, options);
};

from jquery-cookie.

FagnerMartinsBrack avatar FagnerMartinsBrack commented on May 18, 2024

Do u think the options are needed here?
My idea here is simulate the "options.expires = -1" by aliasing $.cookie("name", null) to $.removeCookie for the sake of readability
You may probably be able to do this without testing all the stuff $.cookie does, but I don't think the performance improvement would be noticeable

from jquery-cookie.

carhartl avatar carhartl commented on May 18, 2024

I think yes, it's required. You can only remove the cookie with the same options (path and domain options are the important ones here) that were used to write it in the first place. Basically removing the cookie is nothing else than a write.

You could have written a cookie for different paths:

$.cookie('foo', 'bar', { path: '/one' });
$.removeCookie('foo', { path: '/one' });

$.cookie('foo', 'bar', { path: '/two' });
$.removeCookie('foo', { path: '/two' });

Of course passing options isn't necessary when relying on the default options.

from jquery-cookie.

carhartl avatar carhartl commented on May 18, 2024

Don't think performance is a real issue here, unless you're deleting 1000 cookies in a row maybe.

from jquery-cookie.

FagnerMartinsBrack avatar FagnerMartinsBrack commented on May 18, 2024

Let's consider #87 on this one

from jquery-cookie.

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.