#1 new
Nick Donald

Issue with adding self closing Elements

Reported by Nick Donald | May 16th, 2010 @ 06:14 AM

Was using your excellent foundation this morning on a mobile site we are working on. Found that it returns a 'NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7' on selfclosing elements in WebKit @ least e.g.:

el.appendChild(new Element('img', {'src':'/images/vehicle-search/soldflaglist.gif','class':'soldflag'}));

The following fix to Element method seems to fix he issue:

/* * Simplified element creation function * @param type {string} The type of element to create. * @param atts {object} Attributes to attached to the HTMLElement. (optional) * @param content {string} Set the innerHTML of the element. (optional) / var Element = function(type, atts, content) {

this.el = document.createElement(type);

for(var attr in atts) {
    this.el.setAttribute(attr, atts[attr]);
}
if (!(/(area|base|basefont|br|hr|img|input|link|meta)/).test(type)) //ND - added this line to filter self closing
this.el.innerHTML = content || '';
return this.el;

};

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

baseJS is a lightweight Javascript framework intended for use with Mobile Safari on the iPhone and iPod Touch; it also
works with Firefox and all WebKit-based browsers. By providing shortcuts and reusable methods, baseJS helps you write
code to be lightweight and extendable—perfect for the mobile web.

People watching this ticket

Pages