.clip was not working, the path never made it to the clip area

This commit is contained in:
Jan Potoms 2016-04-16 22:06:25 +02:00
parent c909ae09d7
commit 769f20b0e1
2 changed files with 13 additions and 0 deletions

View File

@ -1029,6 +1029,7 @@
id = randomString(this.__ids), id = randomString(this.__ids),
newGroup = this.__createElement("g"); newGroup = this.__createElement("g");
this.__applyCurrentDefaultPath();
group.removeChild(this.__currentElement); group.removeChild(this.__currentElement);
clipPath.setAttribute("id", id); clipPath.setAttribute("id", id);
clipPath.appendChild(this.__currentElement); clipPath.appendChild(this.__currentElement);

View File

@ -332,4 +332,16 @@ describe('canvas2svg', function() {
expect(svg.querySelector("path").getAttribute("stroke-opacity")).to.equal(''+0.8*0.5); expect(svg.querySelector("path").getAttribute("stroke-opacity")).to.equal(''+0.8*0.5);
}); });
}); });
describe("supports clip", function() {
it("adds clippath", function() {
var ctx = new C2S();
ctx.rect(200, 200, 400, 400);
ctx.clip();
ctx.fillStyle = "#000000";
ctx.rect(100, 100, 300, 300);
var svg = ctx.getSvg();
expect(svg.querySelector("clipPath > path").getAttribute("d")).to.not.equal(null);
});
});
}); });