File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test V8::executeString() : DOM object passed from PHP
3
+ --SKIPIF--
4
+ <?php require_once (dirname (__FILE__ ) . '/skipif.inc ' ); ?>
5
+ --FILE--
6
+ <?php
7
+
8
+ $ JS = <<< EOT
9
+ print('js1: ', PHP.test.length, "\\n");
10
+ var elements = PHP.dom.getElementsByTagName('node');
11
+ print('js2: ', elements.length, "\\n");
12
+ var node = elements.item(0);
13
+ print("hasChildNodes: "); var_dump(node.hasChildNodes());
14
+ print("hasAttribute('class'): "); var_dump(node.hasAttribute('class'));
15
+ //var_dump(node);
16
+ EOT ;
17
+
18
+ $ dom = new DomDocument ();
19
+ $ dom ->loadXML ('<node class="test"/> ' );
20
+
21
+ $ elements = $ dom ->getElementsByTagName ('node ' );
22
+ echo 'php: ' , $ elements ->length , "\n" ;
23
+ $ node = $ elements ->item (0 );
24
+ echo "hasChildNodes: " ; var_dump ($ node ->hasChildNodes ());
25
+ echo "hasAttribute('class'): " ; var_dump ($ node ->hasAttribute ('class ' ));
26
+ //var_dump($node);
27
+
28
+ $ a = new V8Js ();
29
+ $ a ->dom = $ dom ;
30
+ $ a ->test = array ( 'length ' => 1 );
31
+ $ a ->executeString ($ JS , "test.js " );
32
+
33
+ ?>
34
+ ===EOF===
35
+ --EXPECT--
36
+ php: 1
37
+ hasChildNodes: bool(false)
38
+ hasAttribute('class'): bool(true)
39
+ js1: 1
40
+ js2: 1
41
+ hasChildNodes: bool(false)
42
+ hasAttribute('class'): bool(true)
43
+ ===EOF===
You can’t perform that action at this time.
0 commit comments