ryejs / rye Goto Github PK
View Code? Open in Web Editor NEWA modern, lightweight browser library using ES5 natives
Home Page: http://ryejs.com
License: ISC License
A modern, lightweight browser library using ES5 natives
Home Page: http://ryejs.com
License: ISC License
Necessary for #21. Need to figure out how to
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-cdataThe 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
When called on a collection > 1
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))
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.
handler
to same event
. https://github.com/Wolfy87/EventEmitter/blob/master/EventEmitter.js#L91What do you think about both?
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)
}
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']
x.on('keydown[enter] .input', function(e){
//...
})
x.on('keydown[cmd+shift+a]', function(e){
//...
})
document.querySelectorAll('body') instanceof NodeList
false
document.querySelectorAll('body').constructor
NodeList
Based on this post http://blog.millermedeiros.com/jquery-wish-list I want to suggest some modifications:
not
to exclude
has
to filterHas
, ?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?
Implementation error, we shouldn't be manipulating the live childNodes
list.
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;
};
Should be easy, just add the necessary parameters for the Uglify2 minify task.
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
The ajax API can have a emitter and emit events trought that. I will try implement this.
Do you have any other ideia?
The web page states:
util.is(obj, type) ⤳ boolean
Yet the latest master and the downloaded v0.0.1 shows:
function is (kind, obj) {
return kind.indexOf(type(obj)) >= 0
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.