Giter Site home page Giter Site logo

ryejs / rye Goto Github PK

View Code? Open in Web Editor NEW
266.0 266.0 18.0 561 KB

A modern, lightweight browser library using ES5 natives

Home Page: http://ryejs.com

License: ISC License

CoffeeScript 13.07% JavaScript 85.36% CSS 0.69% HTML 0.89%
dom eventemitter javascript library manipulation

rye's People

Contributors

bitdeli-chef avatar extend1994 avatar jcemer avatar ricardobeat avatar wheresrhys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rye's Issues

Extending Rye functions

I've been reading Rye's documentation for 2 hours but can't manage to extend Rye functions as I would with JQuery. For example, what would be Rye's equivalent of this JQuery function?

$.fn.blueBorder = function(){
    this.css({border-color:'blue'})
    return this;
};

Cure this.each disease

What if instead of wrapping almost every function body in return this.each ... like other frameworks, we used an approach similar to flour, where all methods originally operate on a single element, but are patched at the end to support collections?

https://github.com/ricardobeat/cake-flour/blob/master/flour.coffee#L125

This would allow us to be more efficient in applying methods to one another, for example toggleClass:

exports.toggleClass = function(name, when){
    return this.each(function(element){
        if (when == null) {
            when = !new Rye(element).hasClass(name)
        }
        new Rye(element)[(when ? 'add' : 'remove') + 'Class'](name)
    })
}

It creates lots of new instances just to have the methods available. With this approach it could look like this:

exports.toggleClass = function(name, when){
    if (when == null) when = hasClass.call(this, name)
    (when ? addClass : removeClass).call(this, name)
}

bind()ing an event handler makes me lose access to the matched element

Let's say you have

one.on('click .two', function (e, el) {
    // e.target = can be a descendant
    // el == the delegate root
    // this == xxx
}.bind(xxx))

There is no way you can access the actual element (.two). jQuery exposes it as e.currentTarget (I think), along with e.delegateTarget. Should we manipulate the event object too, maybe also normalize e.keyCode/which while we're at it?

Put modules in their own repos

Necessary for #21. Need to figure out how to

  • declare dependencies
  • build full version
  • modules have their own tests, rye does integration tests

util.each should always have the same argument order

Penso que a gente não deva inverter o comportamento do each.

Quando se tá mexendo em coleções que contém tanto arrays quanto objetos esse comportamento é estranho e confuso.

A sugestão é que a gente implemente todos os each como jQuery ou tire qualquer referência a eles da biblioteca apesar de ser super útil ter um atalho para for (var key in obj) if (_hasOwnProperty.call(obj, key))

Library request in cdnjs.

Hi ~
There's a library request in cdnjs, and we desire to contain rye .
However, I must to make a check for the files that we need to added.

The file i would like to add is:

lib/rye.js

Is that complete for the user? Or other files required?

Thanks for your great work ✨

Piicksarn

Should class methods preserve whitespace?

User agents may ignore leading and trailing white space in CDATA attribute values (e.g., " myval " may be interpreted as "myval").
Authors should not declare attribute values with leading or trailing white space.
http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-cdata

The classes that an HTML element has assigned to it consists of all the classes returned when the value of the class attribute is split on spaces. (Duplicates are ignored.)
http://dev.w3.org/html5/spec/single-page.html#classes

The only argument I could find for preserving whitespace comes from a message by Ian Hixie in 2009: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-July/021653.html

He says I try to make the APIs as minimally invasive as possible. This worry seems unfounded in this case. Since whitespace characters are effectively ignored for every possible use of the className property or classList, there is no technical reason to preserve them.

The only case where I think this could be an issue is this:

var old = el.className
$(el).addClass('x').removeClass('x')
if (old === element.className) // fails

But is it reasonable to expect this to work? classList was created exactly to avoid the brittleness of handling strings, and even using the new API this case fails:

var old = el.classList.toString() // == '   x  '
el.classList.remove('x')
el.classList.add('x')
if (old === el.className) // fails since it now == 'x'

And in most other instances (ex: more classes) this would fail too since the order would change (' x y z' => 'y z x').

The only way this could work is if classList methods enforced uniqueness and order, which they don't because of such concerns on being 'intrusive'. I say we should ignore the madness and normalize whitespace, unless someone can come up with a really good use case for whitespace preservation.

Note: order/duplication doesn't matter since specificity is given by the CSS declaration order, not the class attribute - .one.two applies equally to "one two" or "two one", same goes for .one { ... } .two { ... }.

Also of note: Mozilla's provided shim for classList doesn't preserve whitespace: https://developer.mozilla.org/en-US/docs/DOM/element.classList

Remove request and touch modules

These will be moved to their own repos under the RyeJS org. They might still be maintained, but most people will want to use other more feature-complete alternatives.

Add .invoke() method to collections

Since we don't have a few helper methods like focus(), would be nice to have invoke operate on a collection:

form.find('input').invoke('focus')

It could automatically map() over the elements for return values, unlike attr and other methods that return only the first value:

list.find('li').invoke('getAttribute', 'id') // => ['a', 'b', 'c']

Ajax events

The ajax API can have a emitter and emit events trought that. I will try implement this.

Do you have any other ideia?

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.