Don't you think that string should be wrapped with tag like div, span or custom tag if it contains more than one elements? Example: '<img src="foo" id="bar" /><img src="bar" id="bar" / >'.makeElement().toHTML(); // =>'<span><img src="foo" id="bar" /><img src="bar" id="bar" /></span>' '<img src="foo" id="bar" /><img src="bar" id="bar" / >'.makeElement('div').toHTML(); // =>'<div><img src="foo" id="bar" / ><img src="bar" id="bar" /></div>' 'foo'.makeElement('span').toHTML() //=> '<span>foo'</span> <
On Mar 24, 5:39 pm, kangax <[EMAIL PROTECTED]> wrote: > Because of toElement conflict we had to use makeElement in Prototype- > UI. Take a look at the source if you're > interested.http://dev.prototype-ui.com/browse/trunk/src/core/string.js > > - kangax > > On Mar 24, 8:40 am, Станислав Анисимов <[EMAIL PROTECTED]> > wrote: > > > If you think that the functionalities can be useful they can be added > > to Element object like > > Element.replaceClassNames > > Element.cycleClassNames > > > On Mar 24, 3:23 pm, Tobie Langel <[EMAIL PROTECTED]> wrote: > > > > Hi Станислав Анисимов, > > > > Element.ClassNames is deprecated. > > > > Best, > > > > Tobie > > > > On Mar 24, 1:11 pm, Станислав Анисимов <[EMAIL PROTECTED]> > > > wrote: > > > > > Pair of functionalities to String object. Actully i found that > > > > String.toElement method conflicts with Element.update or may be also > > > > with some other functions > > > > > Object.extend(String.prototype, { > > > > > /** > > > > * If the string is html code and enclosed with html element > > > > convert > > > > to Element > > > > * else the string is wraped with <span> or with 1st argument > > > > tag > > > > * > > > > * return {Element} > > > > */ > > > > toElement: function() { > > > > str = this.strip(); > > > > if (!str.startsWith('<') || !str.endsWith('>')){ > > > > wrapTag = arguments[0]||'span'; > > > > str = '<' + wrapTag + '>' + str + '</' + > > > > wrapTag + '>'; > > > > } > > > > > var node = new Element('span'); > > > > node.innerHTML = str; > > > > if (node.childElements().length == 1) { > > > > return node.down(); > > > > } > > > > return node; > > > > }, > > > > > /** > > > > * Extract elements from HTML code with given selector > > > > * > > > > * @param {String} selector > > > > * @return {Array} Array of elements > > > > */ > > > > extractElements: function(selector) { > > > > return this.toElement().select(selector); > > > > } > > > > > }) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---