Skip to content

Commit

Permalink
Merge pull request #2 from svgdotjs/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
kabentley authored Mar 4, 2019
2 parents 3a13639 + 4afd76d commit be9cdd4
Show file tree
Hide file tree
Showing 37 changed files with 1,387 additions and 477 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:

====

## [3.0.12] - 2019-02-19

### Fixed
- fixed package.json which points to correct file for webpack now (browser keyword)
- fixed typescript types

### Added
- added `ForeignObject` to the core

## [3.0.11] - 2019-01-22

### Fixed
Expand Down Expand Up @@ -807,6 +816,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:


<!-- Headings above link to the releases listed here -->
[3.0.12]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.12
[3.0.11]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.11
[3.0.10]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.10
[3.0.9]: https://github.com/svgdotjs/svg.js/releases/tag/3.0.9
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@svgdotjs/svg.js",
"version": "3.0.11",
"version": "3.0.12",
"description": "A lightweight library for manipulating and animating SVG.",
"url": "https://svgdotjs.github.io/",
"homepage": "https://svgdotjs.github.io/",
Expand Down
47 changes: 47 additions & 0 deletions spec/spec/elements/ForeignObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { makeInstance, ForeignObject } from '../../../src/main.js';

const { any, createSpy, objectContaining } = jasmine


describe('ForeignObject.js', () => {

describe('()', () => {
it('creates a new object of type ForeignObject', () => {
expect(new ForeignObject()).toEqual(any(ForeignObject))
})

it('sets passed attributes on the element', () => {
expect(new ForeignObject({id:'foo'}).id()).toBe('foo')
})
})

describe('Container', () => {
describe('foreignObject()', () => {
it('creates a foreignObject in the container', () => {
const canvas = makeInstance().addTo('#canvas')
const foreignObject = canvas.foreignObject()
expect(foreignObject).toEqual(any(ForeignObject))
expect(foreignObject.parent()).toBe(canvas)
})

it('sets width and height correctly on construction', () => {
const canvas = makeInstance().addTo('#canvas')
const foreignObject = canvas.foreignObject(100, 200)
expect(foreignObject.width()).toBe(100)
expect(foreignObject.height()).toBe(200)
})
})
})

describe('Element methods', () => {
it('is usable with Elements methods such as height() and width()', () => {
const canvas = makeInstance().addTo('#canvas')
const foreignObject = canvas.foreignObject()
foreignObject.width(100).height(200).x(10).y(20)
expect(foreignObject.width()).toBe(100)
expect(foreignObject.height()).toBe(200)
expect(foreignObject.x()).toBe(10)
expect(foreignObject.y()).toBe(20)
})
})
})
2 changes: 1 addition & 1 deletion src/animation/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,4 +992,4 @@ extend(Runner, {
})

extend(Runner, { rx, ry, from, to })
register(Runner)
register(Runner, 'Runner')
2 changes: 1 addition & 1 deletion src/elements/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ registerMethods({
}
})

register(A)
register(A, 'A')
4 changes: 2 additions & 2 deletions src/elements/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Circle extends Shape {
extend(Circle, { x, y, cx, cy, width, height })

registerMethods({
Element: {
Container: {
// Create circle element
circle: wrapWithAttrCheck(function (size) {
return this.put(new Circle())
Expand All @@ -46,4 +46,4 @@ registerMethods({
}
})

register(Circle)
register(Circle, 'Circle')
2 changes: 1 addition & 1 deletion src/elements/ClipPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ registerMethods({
}
})

register(ClipPath)
register(ClipPath, 'ClipPath')
2 changes: 1 addition & 1 deletion src/elements/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export default class Container extends Element {
}
}

register(Container)
register(Container, 'Container')
2 changes: 1 addition & 1 deletion src/elements/Defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export default class Defs extends Container {
}
}

register(Defs)
register(Defs, 'Defs')
2 changes: 1 addition & 1 deletion src/elements/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,4 @@ export default class Dom extends EventTarget {
}

extend(Dom, { attr, find, findOne })
register(Dom)
register(Dom, 'Dom')
2 changes: 1 addition & 1 deletion src/elements/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ extend(Element, {
bbox, rbox, point, ctm, screenCTM
})

register(Element)
register(Element, 'Element')
2 changes: 1 addition & 1 deletion src/elements/Ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ registerMethods('Container', {
})
})

register(Ellipse)
register(Ellipse, 'Ellipse')
19 changes: 19 additions & 0 deletions src/elements/ForeignObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import Element from './Element.js'

export default class ForeignObject extends Element {
constructor (node) {
super(nodeOrNew('foreignObject', node), node)
}
}

registerMethods({
Container: {
foreignObject: wrapWithAttrCheck(function (width, height) {
return this.put(new ForeignObject()).size(width, height)
})
}
})

register(ForeignObject, 'ForeignObject')
4 changes: 2 additions & 2 deletions src/elements/G.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ export default class G extends Container {
}

registerMethods({
Element: {
Container: {
// Create a group element
group: wrapWithAttrCheck(function () {
return this.put(new G())
})
}
})

register(G)
register(G, 'G')
2 changes: 1 addition & 1 deletion src/elements/Gradient.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ registerMethods({
}
})

register(Gradient)
register(Gradient, 'Gradient')
2 changes: 1 addition & 1 deletion src/elements/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ registerMethods({
}
})

register(Image)
register(Image, 'Image')
2 changes: 1 addition & 1 deletion src/elements/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ registerMethods({
}
})

register(Line)
register(Line, 'Line')
2 changes: 1 addition & 1 deletion src/elements/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ registerMethods({
}
})

register(Marker)
register(Marker, 'Marker')
2 changes: 1 addition & 1 deletion src/elements/Mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ registerMethods({
}
})

register(Mask)
register(Mask, 'Mask')
2 changes: 1 addition & 1 deletion src/elements/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ registerMethods({
}
})

register(Path)
register(Path, 'Path')
2 changes: 1 addition & 1 deletion src/elements/Pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ registerMethods({
}
})

register(Pattern)
register(Pattern, 'Pattern')
2 changes: 1 addition & 1 deletion src/elements/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ registerMethods({

extend(Polygon, pointed)
extend(Polygon, poly)
register(Polygon)
register(Polygon, 'Polygon')
2 changes: 1 addition & 1 deletion src/elements/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ registerMethods({

extend(Polyline, pointed)
extend(Polyline, poly)
register(Polyline)
register(Polyline, 'Polyline')
2 changes: 1 addition & 1 deletion src/elements/Rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ registerMethods({
}
})

register(Rect)
register(Rect, 'Rect')
2 changes: 1 addition & 1 deletion src/elements/Shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Element from './Element.js'

export default class Shape extends Element {}

register(Shape)
register(Shape, 'Shape')
2 changes: 1 addition & 1 deletion src/elements/Stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export default class Stop extends Element {
}
}

register(Stop)
register(Stop, 'Stop')
2 changes: 1 addition & 1 deletion src/elements/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ registerMethods('Dom', {
})
})

register(Style)
register(Style, 'Style')
2 changes: 1 addition & 1 deletion src/elements/Symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ registerMethods({
}
})

register(Symbol)
register(Symbol, 'Symbol')
2 changes: 1 addition & 1 deletion src/elements/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,4 @@ registerMethods({
}
})

register(Text)
register(Text, 'Text')
2 changes: 1 addition & 1 deletion src/elements/TextPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ registerMethods({
})

TextPath.prototype.MorphArray = PathArray
register(TextPath)
register(TextPath, 'TextPath')
2 changes: 1 addition & 1 deletion src/elements/Tspan.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ registerMethods({
}
})

register(Tspan)
register(Tspan, 'Tspan')
2 changes: 1 addition & 1 deletion src/elements/Use.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ registerMethods({
}
})

register(Use)
register(Use, 'Use')
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export { default as Defs } from './elements/Defs.js'
export { default as Dom } from './elements/Dom.js'
export { default as Element } from './elements/Element.js'
export { default as Ellipse } from './elements/Ellipse.js'
export { default as ForeignObject } from './elements/ForeignObject.js'
export { default as Gradient } from './elements/Gradient.js'
export { default as G } from './elements/G.js'
export { default as A } from './elements/A.js'
Expand Down
2 changes: 1 addition & 1 deletion src/types/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,4 @@ registerMethods({
}
})

register(Box)
register(Box, 'Box')
2 changes: 1 addition & 1 deletion src/types/EventTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ export default class EventTarget extends Base {
removeEventListener () {}
}

register(EventTarget)
register(EventTarget, 'EventTarget')
2 changes: 1 addition & 1 deletion src/types/Matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,4 @@ export function screenCTM () {
return new Matrix(this.node.getScreenCTM())
}

register(Matrix)
register(Matrix, 'Matrix')
Loading

0 comments on commit be9cdd4

Please sign in to comment.