Heya,
Thanks for providing this patch, but for various reasons discussed
earlier on this mailing list (and on Prototype core), we will not
patch purely because of what a given JavaScript interpreter might or
might not interpret as "questionable code".
Best,
Thomas
Am 11.07.2007 um 13:59 schrieb goutnet:
>
> I attach (copy/paste) a patch to make last prototype.js warning free
> under latest firefox
>
> I hope it will be usefull to some others
>
> (please correct me if I made any mistake)
>
> Florian Delizy
>
> Index: prototype.js
> ===================================================================
> --- prototype.js (révision 444)
> +++ prototype.js (copie de travail)
> @@ -65,12 +65,12 @@
> switch(type) {
> case 'undefined':
> case 'function':
> - case 'unknown': return;
> + case 'unknown': return '';
> case 'boolean': return object.toString();
> }
> if (object === null) return 'null';
> if (object.toJSON) return object.toJSON();
> - if (object.ownerDocument === document) return;
> + if (object.ownerDocument === document) return '';
> var results = [];
> for (var property in object) {
> var value = Object.toJSON(object[property]);
> @@ -106,7 +106,7 @@
> }
> }
>
> -Function.prototype.bindAsEventListener = function(object) {
> +Function.prototype.bindAsEventListener = function(object_) {
> var __method = this, args = $A(arguments), object = args.shift();
> return function(event) {
> return __method.apply(object, [event ||
> window.event].concat(args));
> @@ -215,7 +215,7 @@
> replacement = arguments.callee.prepareReplacement(replacement);
>
> while (source.length > 0) {
> - if (match = source.match(pattern)) {
> + if ((match = source.match(pattern))) {
> result += source.slice(0, match.index);
> result += String.interpret(replacement(match));
> source = source.slice(match.index + match[0].length);
> @@ -470,7 +470,7 @@
> any: function(iterator) {
> var result = false;
> this.each(function(value, index) {
> - if (result = !!(iterator || Prototype.K)(value, index))
> + if ((result = !!(iterator || Prototype.K)(value, index)))
> throw $break;
> });
> return result;
> @@ -895,7 +895,7 @@
> iterator(pair);
> }
> };
> -ObjectRange = Class.create();
> +var ObjectRange = Class.create();
> Object.extend(ObjectRange.prototype, Enumerable);
> Object.extend(ObjectRange.prototype, {
> initialize: function(start, end, exclusive) {
> @@ -1019,7 +1019,7 @@
>
> this.parameters = params;
>
> - if (params = Hash.toQueryString(params)) {
> + if ((params = Hash.toQueryString(params))) {
> // when GET, append parameters to URL
> if (this.method == 'get')
> this.url += (this.url.include('?') ? '&' : '?') + params;
> @@ -1151,6 +1151,7 @@
> } catch (e) {
> this.dispatchException(e);
> }
> + return '';
> },
>
> dispatchException: function(exception) {
> @@ -1186,7 +1187,7 @@
>
> if (!this.options.evalScripts) response =
> response.stripScripts();
>
> - if (receiver = $(receiver)) {
> + if ((receiver = $(receiver))) {
> if (this.options.insertion)
> new this.options.insertion(receiver, response);
> else
> @@ -1382,7 +1383,7 @@
> recursivelyCollect: function(element, property) {
> element = $(element);
> var elements = [];
> - while (element = element[property])
> + while ((element = element[property]))
> if (element.nodeType == 1)
> elements.push(Element.extend(element));
> return elements;
> @@ -1495,7 +1496,7 @@
> },
>
> hasClassName: function(element, className) {
> - if (!(element = $(element))) return;
> + if (!(element = $(element))) return false;
> var elementClassName = element.className;
> if (elementClassName.length == 0) return false;
> if (elementClassName == className ||
> @@ -1505,19 +1506,19 @@
> },
>
> addClassName: function(element, className) {
> - if (!(element = $(element))) return;
> + if (!(element = $(element))) return '';
> Element.classNames(element).add(className);
> return element;
> },
>
> removeClassName: function(element, className) {
> - if (!(element = $(element))) return;
> + if (!(element = $(element))) return '';
> Element.classNames(element).remove(className);
> return element;
> },
>
> toggleClassName: function(element, className) {
> - if (!(element = $(element))) return;
> + if (!(element = $(element))) return '';
> Element.classNames(element)[element.hasClassName(className) ?
> 'remove' : 'add'](className);
> return element;
> },
> @@ -1551,7 +1552,7 @@
>
> descendantOf: function(element, ancestor) {
> element = $(element), ancestor = $(ancestor);
> - while (element = element.parentNode)
> + while ((element = element.parentNode))
> if (element == ancestor) return true;
> return false;
> },
> @@ -1696,7 +1697,7 @@
> if (!value && element.currentStyle) value =
> element.currentStyle[style];
>
> if (style == 'opacity') {
> - if (value = (element.getStyle('filter') || '').match(/alpha\
> (opacity=(.*)\)/))
> + if ((value = (element.getStyle('filter') || '').match(/alpha\
> (opacity=(.*)\)/)))
> if (value[1]) return parseFloat(value[1]) / 100;
> return 1.0;
> }
> @@ -2064,7 +2065,7 @@
> c = Selector.criteria, le, p, m;
>
> if (Selector._cache[e]) {
> - this.matcher = Selector._cache[e]; return;
> + this.matcher = Selector._cache[e]; return '';
> }
> this.matcher = ["this.matcher = function(root) {",
> "var r = root, h = Selector.handlers, c = false,
> n;"];
> @@ -2073,7 +2074,7 @@
> le = e;
> for (var i in ps) {
> p = ps[i];
> - if (m = e.match(p)) {
> + if ((m = e.match(p))) {
> this.matcher.push(typeof c[i] == 'function' ? c[i](m) :
> new Template(c[i]).evaluate(m));
> e = e.replace(m[0], '');
> @@ -2085,6 +2086,7 @@
> this.matcher.push("return h.unique(n);\n}");
> eval(this.matcher.join('\n'));
> Selector._cache[this.expression] = this.matcher;
> + return '';
> },
>
> compileXPathMatcher: function() {
> @@ -2099,7 +2101,7 @@
> while (e && le != e && (/\S/).test(e)) {
> le = e;
> for (var i in ps) {
> - if (m = e.match(ps[i])) {
> + if ((m = e.match(ps[i]))) {
> this.matcher.push(typeof x[i] == 'function' ? x[i](m) :
> new Template(x[i]).evaluate(m));
> e = e.replace(m[0], '');
> @@ -2174,15 +2176,15 @@
> 'checked': "[EMAIL PROTECTED]",
> 'disabled': "[EMAIL PROTECTED]",
> 'enabled': "[not(@disabled)]",
> - 'not': function(m) {
> - var e = m[6], p = Selector.patterns,
> + 'not': function(m_) {
> + var e = m_[6], p = Selector.patterns,
> x = Selector.xpath, le, m, v;
>
> var exclusion = [];
> while (e && le != e && (/\S/).test(e)) {
> le = e;
> for (var i in p) {
> - if (m = e.match(p[i])) {
> + if ((m = e.match(p[i]))) {
> v = typeof x[i] == 'function' ? x[i](m) : new
> Template(x[i]).evaluate(m);
> exclusion.push("(" + v.substring(1, v.length - 1) +
> ")");
> e = e.replace(m[0], '');
> @@ -2217,9 +2219,9 @@
> var mm, formula = m[6], predicate;
> if (formula == 'even') formula = '2n+0';
> if (formula == 'odd') formula = '2n+1';
> - if (mm = formula.match(/^(\d+)$/)) // digit only
> + if ((mm = formula.match(/^(\d+)$/))) // digit only
> return '[' + fragment + "= " + mm[1] + ']';
> - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
> + if ((mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/))) { // an
> +b
> if (mm[1] == "-") mm[1] = -1;
> var a = mm[1] ? Number(mm[1]) : 1;
> var b = mm[2] ? Number(mm[2]) : 0;
> @@ -2228,6 +2230,7 @@
> return new Template(predicate).evaluate({
> fragment: fragment, a: a, b: b });
> }
> + return '';
> }
> }
> },
> @@ -2351,13 +2354,13 @@
> },
>
> nextElementSibling: function(node) {
> - while (node = node.nextSibling)
> + while ((node = node.nextSibling))
> if (node.nodeType == 1) return node;
> return null;
> },
>
> previousElementSibling: function(node) {
> - while (node = node.previousSibling)
> + while ((node = node.previousSibling))
> if (node.nodeType == 1) return node;
> return null;
> },
> @@ -2519,7 +2522,7 @@
> formula = Number(formula);
> for (var i = 0, node; node = nodes[i]; i++)
> if (node.nodeIndex == formula) results.push(node);
> - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { //
> an+b
> + } else if ((m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)))
> { // an+b
> if (m[1] == "-") m[1] = -1;
> var a = m[1] ? Number(m[1]) : 1;
> var b = m[2] ? Number(m[2]) : 0;
> @@ -2598,8 +2601,8 @@
> return Selector.matchElements(elements, expression || '*')[index
> || 0];
> },
>
> - findChildElements: function(element, expressions) {
> - var exprs = expressions.join(','), expressions = [];
> + findChildElements: function(element, expressions_) {
> + var exprs = expressions_.join(','), expressions = [];
> exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,
> function(m) {
> expressions.push(m[1].strip());
> });
> @@ -3145,6 +3148,7 @@
> if (mode == 'horizontal')
> return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
> element.offsetWidth;
> + return 0;
> },
>
> page: function(forElement) {
> @@ -3159,7 +3163,7 @@
> if (element.offsetParent == document.body)
> if (Element.getStyle(element,'position')=='absolute') break;
>
> - } while (element = element.offsetParent);
> + } while ((element = element.offsetParent));
>
> element = forElement;
> do {
> @@ -3167,7 +3171,7 @@
> valueT -= element.scrollTop || 0;
> valueL -= element.scrollLeft || 0;
> }
> - } while (element = element.parentNode);
> + } while ((element = element.parentNode));
>
> return [valueL, valueT];
> },
> @@ -3268,4 +3272,4 @@
> }
> }
>
> -Element.addMethods();
> \ Pas de fin de ligne à la fin du fichier
> +Element.addMethods();
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---