File tree Expand file tree Collapse file tree 6 files changed +50
-1
lines changed Expand file tree Collapse file tree 6 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -646,7 +646,14 @@ protected function replacePre(string $html): string
646646 public function replaceShowWithIf (DOMElement $ node ): void
647647 {
648648 if ($ node ->hasAttribute ('v-show ' )) {
649- $ node ->setAttribute ('v-if ' , $ node ->getAttribute ('v-show ' ));
649+ if ($ node ->hasAttribute ('v-if ' )) {
650+ $ node ->setAttribute (
651+ 'v-if ' ,
652+ '( ' . $ node ->getAttribute ('v-if ' ) . ') && ( ' . $ node ->getAttribute ('v-show ' ) . ') '
653+ );
654+ } else {
655+ $ node ->setAttribute ('v-if ' , $ node ->getAttribute ('v-show ' ));
656+ }
650657 $ node ->removeAttribute ('v-show ' );
651658 }
652659 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Paneon \VueToTwig \Tests ;
4+
5+ use Exception ;
6+
7+ class VueShowTest extends AbstractTestCase
8+ {
9+ /**
10+ * @dataProvider showProvider
11+ *
12+ * @param mixed $html
13+ * @param mixed $expected
14+ *
15+ * @throws Exception
16+ */
17+ public function testIf ($ html , $ expected )
18+ {
19+ $ compiler = $ this ->createCompiler ($ html );
20+
21+ $ actual = $ compiler ->convert ();
22+
23+ $ this ->assertEqualHtml ($ expected , $ actual );
24+ }
25+
26+ public function showProvider ()
27+ {
28+ return $ this ->loadFixturesFromDir ('vue-show ' );
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ {% if foo %}
2+ <div class =" {{ class | default (' ' ) }}" style =" {{ style | default (' ' ) }}" >Text</div >
3+ {% endif %}
Original file line number Diff line number Diff line change 1+ <template >
2+ <div v-show =" foo" >Text</div >
3+ </template >
Original file line number Diff line number Diff line change 1+ {% if (foo ) and (bar ) %}
2+ <div class =" {{ class | default (' ' ) }}" style =" {{ style | default (' ' ) }}" >Text</div >
3+ {% endif %}
Original file line number Diff line number Diff line change 1+ <template >
2+ <div v-if =" foo" v-show =" bar" >Text</div >
3+ </template >
You can’t perform that action at this time.
0 commit comments