mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Allow setting of styles/properties via objects.
Additionally: 1. Make the type for setting attributes via objects slightly stricter. 2. Add tests for style/property setting via object maps.
This commit is contained in:
@@ -2286,6 +2286,21 @@ function attrObjTest () {
|
||||
.attr({"xlink:href": function(d, i) { return d + "-" + i + ".png"; }});
|
||||
}
|
||||
|
||||
// Test for setting styles as an object
|
||||
// From https://github.com/mbostock/d3/blob/master/test/selection/style-test.js
|
||||
function styleObjTest () {
|
||||
d3.select('body')
|
||||
.style({"background-color": "white", opacity: .42});
|
||||
}
|
||||
|
||||
// Test for setting styles as an object
|
||||
// From https://github.com/mbostock/d3/blob/master/test/selection/property-test.js
|
||||
function propertyObjTest () {
|
||||
d3.select('body')
|
||||
.property({bgcolor: "purple", opacity: .41});
|
||||
}
|
||||
|
||||
|
||||
// Test for brushes
|
||||
// This triggers a bug (shown below) in the 0.9.0 compiler, but works with
|
||||
// 0.9.1 compiler.
|
||||
|
||||
4
d3/d3.d.ts
vendored
4
d3/d3.d.ts
vendored
@@ -710,7 +710,7 @@ declare module D3 {
|
||||
(name: string): string;
|
||||
(name: string, value: any): Selection;
|
||||
(name: string, valueFunction: (data: any, index: number) => any): Selection;
|
||||
(attrValueMap : any): Selection;
|
||||
(attrValueMap : Object): Selection;
|
||||
};
|
||||
|
||||
classed: {
|
||||
@@ -723,12 +723,14 @@ declare module D3 {
|
||||
(name: string): string;
|
||||
(name: string, value: any, priority?: string): Selection;
|
||||
(name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection;
|
||||
(styleValueMap : Object): Selection;
|
||||
};
|
||||
|
||||
property: {
|
||||
(name: string): void;
|
||||
(name: string, value: any): Selection;
|
||||
(name: string, valueFunction: (data: any, index: number) => any): Selection;
|
||||
(propertyValueMap : Object): Selection;
|
||||
};
|
||||
|
||||
text: {
|
||||
|
||||
Reference in New Issue
Block a user