Merge branch 'dev' of https://github.com/adobe-webplatform/Snap.svg into dev
commit
c2a42eef50
28
src/svg.js
28
src/svg.js
|
@ -1657,6 +1657,20 @@ function arrayFirstValue(arr) {
|
||||||
el.paper = this.paper;
|
el.paper = this.paper;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
/*\
|
||||||
|
* Element.appendTo
|
||||||
|
[ method ]
|
||||||
|
**
|
||||||
|
* Appends the current element to the given one
|
||||||
|
**
|
||||||
|
- el (Element) parent element to append to
|
||||||
|
= (Element) the child element
|
||||||
|
\*/
|
||||||
|
elproto.appendTo = function (el) {
|
||||||
|
el = wrap(el);
|
||||||
|
el.append(this);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.prepend
|
* Element.prepend
|
||||||
[ method ]
|
[ method ]
|
||||||
|
@ -1672,6 +1686,20 @@ function arrayFirstValue(arr) {
|
||||||
el.paper = this.paper;
|
el.paper = this.paper;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
/*\
|
||||||
|
* Element.prependTo
|
||||||
|
[ method ]
|
||||||
|
**
|
||||||
|
* Prepends the current element to the given one
|
||||||
|
**
|
||||||
|
- el (Element) parent element to prepend to
|
||||||
|
= (Element) the child element
|
||||||
|
\*/
|
||||||
|
elproto.prependTo = function (el) {
|
||||||
|
el = wrap(el);
|
||||||
|
el.prepend(this);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
/*\
|
/*\
|
||||||
* Element.before
|
* Element.before
|
||||||
[ method ]
|
[ method ]
|
||||||
|
|
|
@ -51,6 +51,13 @@ describe("Element methods", function () {
|
||||||
expect(rect2.node.parentNode).to.be(s.node);
|
expect(rect2.node.parentNode).to.be(s.node);
|
||||||
expect(result).to.be(s);
|
expect(result).to.be(s);
|
||||||
});
|
});
|
||||||
|
it("Element.appendTo", function() {
|
||||||
|
var rect = s.rect(10, 20, 30, 40);
|
||||||
|
var result = rect.appendTo(s);
|
||||||
|
expect(rect.node.parentNode).to.be(s.node);
|
||||||
|
expect(s.node.lastChild).to.be(rect.node);
|
||||||
|
expect(result).to.be(rect);
|
||||||
|
});
|
||||||
it("Element.after", function() {
|
it("Element.after", function() {
|
||||||
var circle = s.circle(10, 20, 30);
|
var circle = s.circle(10, 20, 30);
|
||||||
var rect = s.rect(10, 20, 30, 40);
|
var rect = s.rect(10, 20, 30, 40);
|
||||||
|
@ -70,6 +77,18 @@ describe("Element methods", function () {
|
||||||
expect(group.node.firstChild).to.be(circle.node);
|
expect(group.node.firstChild).to.be(circle.node);
|
||||||
expect(result).to.be(group);
|
expect(result).to.be(group);
|
||||||
});
|
});
|
||||||
|
it("Element.prependTo", function() {
|
||||||
|
var rect = s.rect(10, 20, 30, 40);
|
||||||
|
var circle = s.circle(10, 20, 30);
|
||||||
|
var group = s.group();
|
||||||
|
s.append(group);
|
||||||
|
var result = rect.prependTo(group);
|
||||||
|
expect(group.node.firstChild).to.be(rect.node);
|
||||||
|
expect(result).to.be(rect);
|
||||||
|
result = circle.prependTo(group);
|
||||||
|
expect(group.node.firstChild).to.be(circle.node);
|
||||||
|
expect(result).to.be(circle);
|
||||||
|
});
|
||||||
it("Element.insertAfter", function() {
|
it("Element.insertAfter", function() {
|
||||||
var circle = s.circle(10, 20, 30);
|
var circle = s.circle(10, 20, 30);
|
||||||
var rect = s.rect(10, 20, 30, 40);
|
var rect = s.rect(10, 20, 30, 40);
|
||||||
|
|
Loading…
Reference in New Issue