Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ Element.prototype = Object.create(ContainerNode.prototype, {

// Set the attribute without error checking. The parser uses this.
_setAttribute: { value: function _setAttribute(qname, value) {
if (this.namespaceURI === NAMESPACE.SVG) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been reviewing the code a bit more; could we possibly add it here?

domino/lib/svg.js

Lines 19 to 31 in a9e9e17

var SVGElement = define({
superclass: Element,
name: 'SVGElement',
ctor: function SVGElement(doc, localName, prefix) {
Element.call(this, doc, localName, utils.NAMESPACE.SVG, prefix);
},
props: {
style: { get: function() {
if (!this._style)
this._style = new CSSStyleDeclaration(this);
return this._style;
}}
}

if (utils.toASCIILowerCase(qname) === 'attributename') {
qname = 'attributeName';
}
}
// XXX: the spec says that this next search should be done
// on the local name, but I think that is an error.
// email pending on www-dom about it.
Expand Down
17 changes: 17 additions & 0 deletions test/domino.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,23 @@ exports.createSvgElements = function() {
document.body.innerHTML.should.equal("<svg></svg>");
};

exports.svgAttributeNameAdjustmentsFromSetAttribute = function() {
var document = domino.createDocument();
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
var set = document.createElementNS("http://www.w3.org/2000/svg", "set");

set.setAttribute("attributename", "href");
set.setAttribute("to", "javascript:alert(1)");
svg.appendChild(set);
document.body.appendChild(svg);

set.getAttribute("attributeName").should.equal("href");
(set.getAttribute("attributename") === null).should.be.true();
document.body.innerHTML.should.equal(
'<svg><set attributeName="href" to="javascript:alert(1)"></set></svg>'
);
};

exports.gh95 = function() {
var document = domino.createDocument(
'<body><a href="foo\'s">bar</a></body>'
Expand Down