SteveSanderson/knockout — pull request #454 by darklajid (2012-04-28 16:48:46+00:00)
Title: Support svg elements in css: bindings

Fix for bug #453:

This change against master checks if element.className has a property baseVal and reads/updates that instead. For normal elements the behavior should be unchanged. For svg content (see bug for jsFiddle link) this allows css: { .. } bindings.

I tried to make this as little intrusive as possible. The only problem I encountered was convincing the closure compiler to keep my 'baseVal' property intact. I solved that by accessing element.className['baseVal'] instead of .baseVal.

Both debug and production version build and work on my machine. Credits for the solution go in parts to the d3.js project - I knew that they handle setting classes on svg elements and checked their implementation.