CARVIEW |
-
JavaScript inline documentation parserUpdated Tue Apr 07 22:18:12 -0700 2009
-
Prototype JavaScript frameworkForked from sstephenson/prototype Fri Dec 12 04:59:10 -0800 2008
-
Prototype JavaScript frameworkForked from sstephenson/prototype Thu Dec 11 01:30:49 -0800 2008
-
A sizzlin' hot selector engine.Forked from jeresig/sizzle Mon Dec 15 00:24:04 -0800 2008
-
Updated Sat Dec 13 11:23:53 -0800 2008
-
Updated Sat Dec 13 12:01:01 -0800 2008
Public Activity
Actually, in one version of Opera (9.25, perhaps):
<pre><code>
<div title="foo" />
div.getAttribute(‘title’);
// -> ’’
div.title;
// -> ‘foo’
</code></pre>
Sure – But, I’ll want you to review it ;)
Indeed, it’s right in there. I’d like to discuss the API for this a bit more:
deep
argument should be optional and default tofalse
.
<pre>
clone: function(element, deep) {
if (!(element = $(element))) return;
deep = !!deep;
var clone = element.cloneNode(deep);
// ...
</pre>- there should be a simple way to remove
id
attributes. This can be done either by using a third argument as a boolean which would handle this:
<pre>
clone: function(element, deep, removeId) {
if (!(element = $(element))) return;
var clone = element.cloneNode(deep);
clone._prototypeUID = void 0;
if (removeId) clone.id = ’’;
if (deep) {
var descendants = Element.select(clone, ‘‘),
i = descendants.length;
while (i—) {
descendants[i]._prototypeUID = void 0;
if (removeId) descendants[i].id = ’’;
}
}
return Element.extend(clone);
}
// API:
$(element).clone(true, true);
</pre>
or by adding an optional callback which would receive the dom node as first and only argument.
<pre>
clone: function(element, deep, callback) {
if (!(element = $(element))) return;
var clone = element.cloneNode(deep);
clone._prototypeUID = void 0;
if (callback) callback(clone);
if (deep) {
var descendants = Element.select(clone, ‘‘),
i = descendants.length;
while (i—) {
descendants[i]._prototypeUID = void 0;
if (callback) callback(descendants[i]);
}
}
return Element.extend(clone);
}
// API:
$(element).clone(true, function(e) { e.id = ’’; });
</pre>
I think I finder the later more elegant and useful. Thoughts?
Thanks!
LGTM
I think we should target Safari 2.0.4 (that is, fully patched version of 2.0) which solves this problem altogether.
- Missing deprecation helper modifications
The actual code is missing, here.
This really would need tests.
I’m a bit uneasy about this feature test. We’re interested in making sure that the content attached to a script element is evaluated. Here we’re testing that it’s doesn’t throw an error. That’s very different, imho.
This is missing a test to verify
Element#update
correctly evaluates the content it is passed.
Could we possibly clean this up?
To something like this, maybe:
<pre><code>
for (var i = 0; element = elements[i]; i++) {
if (serializers[element.tagName.toLowerCase()])
arr.push(Element.extend(element));
}
return arr;
</code></pre>
The comment has since been removed.
The comment has since been removed.
That wouldn’t work, actually. you’d need to do:
<pre>if (Object.isUndefined(window.console)) return;</pre>
or:
<pre>if (typeof console === ‘undefined’) return;</pre>
Also, it might be worth returning earlier than that (at runtime, form example).
Thanks for your input.