I think extending
setAttribute is the best solution to the original stated problem when weighing the various points made above. It removes the concerns about forward/backward compatibility of
createElement; it avoids the discussion of properties vs. attributes; it accomplishes the goal of reducing the number of repetitions of
el.setAttribute following the
el = document.createElement() line from
1; and it should be very intuitive to anyone who is already familiar with the two argument version of
setAttribute('key', 'value'). I’d also feel comfortable speculating that it would be easier for vendors to implement. Win, win, win?