jQuery: tests now cast to svgjs.LinkedHTMLElement

This could be made implicit by extending the JQuery interface with:
get(index: number): svgjs.LinkedHTMLElement;

Looking at the library it didn't seem sensible to create a dependency on
jQuery even though the tests have one.
This commit is contained in:
John Reilly
2014-03-14 10:51:24 +00:00
parent 246e0785b8
commit cfde90d4e7
2 changed files with 4 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/// <reference path='svgjs.d.ts' />
/// <reference path='../jquery/jquery.d.ts' />
/// <reference path='svgjs.d.ts' />
// create svg drawing paper
@@ -46,7 +46,7 @@ function renderSVG(data:string) {
var container = SVG(div) // this creates an SVG tag inside
container.svg(data) // this creates an SVG inside the SVG
var $inner = $(div).find("svg svg")
var inner:svgjs.Element = $inner.get(0).instance
var inner:svgjs.Element = (<svgjs.LinkedHTMLElement>$inner.get(0)).instance
// Copy in the important attributes
root.attr('x', inner.attr('x'))
@@ -61,8 +61,8 @@ function renderSVG(data:string) {
// Activate and Label all child paths
var index = 0
el.find("rect, path, circle, ellipse").each(function() {
var $path = $(this)
var path = $path.get(0).instance
var $path: JQuery = $(this)
var path = (<svgjs.LinkedHTMLElement>$path.get(0)).instance
var uniqueId = "path"+index++
path.attr({"path-id": uniqueId})
})

8
svgjs/svgjs.d.ts vendored
View File

@@ -270,11 +270,3 @@ declare module svgjs {
f?: number;
}
}
interface JQuery {
/**
* Retrieve one of the elements matched by the jQuery object.
*
* @param index A zero-based integer indicating which element to retrieve.
*/
get(index: number): svgjs.LinkedHTMLElement;
}