knockout/knockout — pull request #1066 by rampion (2013-08-07 19:29:29+00:00)
Title: Support namespaced attributes with default attr binding

When using knockout to create manage SVG or XML nodes, it is sometimes desirable to have it manage attributes from specific namespaces. For example, links in SVG documents use the `xlink` namespace. Currently, the `attr` binding doesn't support attribute namespaces, as can be seen in [this fiddle](http://jsfiddle.net/ZghP7/). The hardcoded `xlink:href` works as a link, while the `xlink:href` attribute created by knockout doesn't, because it doesn't have the right namespace.

This could certainly be compensated for by creating a `attr-ns` binding just to handle namespaced attributes, however not only would this have a high degree of code repetition, but this breaks the similarity between hardcoded attribute and attributes defined by `attr`. The HTML parser is smart enough to figure out which attributes have namespaces, why shouldn't knockout do the same? The DOM provides the `Node.lookupNamespaceURI()`, `Node.setAttributeNS()` and `Node.removeAttributeNS()` methods just for this purpose.

This pull request uses these API functions to add namespace support to the default `attr` binding. It also adds a test to the spec to check that namespace support is working properly.

ref: http://stackoverflow.com/questions/18083723/how-can-i-get-knockout-js-to-set-the-namespaceuri-for-attributes