File tree 3 files changed +27
-27
lines changed
3 files changed +27
-27
lines changed Original file line number Diff line number Diff line change
1
+ import namespace from "./namespace" ;
2
+
3
+ function creatorInherit ( name ) {
4
+ return function ( ) {
5
+ var document = this . ownerDocument ,
6
+ uri = this . namespaceURI ;
7
+ return uri && uri !== document . documentElement . namespaceURI
8
+ ? document . createElementNS ( uri , name )
9
+ : document . createElement ( name ) ;
10
+ } ;
11
+ }
12
+
13
+ function creatorFixed ( fullname ) {
14
+ return function ( ) {
15
+ return this . ownerDocument . createElementNS ( fullname . space , fullname . local ) ;
16
+ } ;
17
+ }
18
+
19
+ export default function ( name ) {
20
+ var fullname = namespace ( name ) ;
21
+ return ( fullname . local
22
+ ? creatorFixed
23
+ : creatorInherit ) ( fullname ) ;
24
+ }
Original file line number Diff line number Diff line change 1
- import namespace from "../namespace " ;
1
+ import creator from "../creator " ;
2
2
import selector from "../selector" ;
3
3
4
- function creatorInherit ( name ) {
5
- return function ( ) {
6
- var document = this . ownerDocument ,
7
- uri = this . namespaceURI ;
8
- return uri && uri !== document . documentElement . namespaceURI
9
- ? document . createElementNS ( uri , name )
10
- : document . createElement ( name ) ;
11
- } ;
12
- }
13
-
14
- function creatorFixed ( fullname ) {
15
- return function ( ) {
16
- return this . ownerDocument . createElementNS ( fullname . space , fullname . local ) ;
17
- } ;
18
- }
19
-
20
- function creator ( name ) {
21
- var fullname = namespace ( name ) ;
22
- return ( fullname . local
23
- ? creatorFixed
24
- : creatorInherit ) ( fullname ) ;
25
- }
26
-
27
4
function append ( create ) {
28
5
return function ( ) {
29
6
return this . appendChild ( create . apply ( this , arguments ) ) ;
Original file line number Diff line number Diff line change @@ -3,10 +3,9 @@ var tape = require("tape"),
3
3
d3 = require ( "../../" ) ;
4
4
5
5
tape ( "d3.selection() returns a selection of the document element" , function ( test ) {
6
+ var document = global . document = jsdom . jsdom ( ) ;
6
7
try {
7
- var document = global . document = jsdom . jsdom ( ) ,
8
- s = d3 . selection ( ) ;
9
- test . equal ( s . node ( ) , document . documentElement ) ;
8
+ test . equal ( d3 . selection ( ) . node ( ) , document . documentElement ) ;
10
9
test . end ( ) ;
11
10
} finally {
12
11
delete global . document ;
You can’t perform that action at this time.
0 commit comments