This project is archived and is in readonly mode.

#330 ✓invalid
Daniel Steigerwald

outerHTML for newElement and Element.Properties

Reported by Daniel Steigerwald | August 23rd, 2008 @ 08:24 PM | in 2.0 (closed)

Small update which is useful for me, maybe for others.


newElement: function(par, props) {
        if (par.contains('<')) {
            var el = this.createElement('div');
            el.innerHTML = par;
            return $.element(el.firstChild);
        }
        else {
            var tag = par;
            if (Browser.Engine.trident && props) {
                ['name', 'type', 'checked'].each(function(attribute) {
                    if (!props[attribute]) return;
                    tag += ' ' + attribute + '="' + props[attribute] + '"';
                    if (attribute != 'checked') delete props[attribute];
                });
                tag = '<' + tag + '>';
            }
            return $.element(this.createElement(tag)).set(props);
        }
    },

And property:


Element.Properties.extend({

    outerhtml: {
        get: Browser.Engine.trident
            ? function() { return this.outerHTML; }
            : function() { return this.getDocument().newElement('div').adopt(this.clone(true)).innerHTML }
    }
});

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Referenced by

Pages