Skip to content

Commit 3eabb46

Browse files
committed
Fix pseudo bug with after and conditionals
1 parent ad9c666 commit 3eabb46

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/Hook/PseudoMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function matches($element) {
2626
foreach ($this->pseudo as $i => $tokens) {
2727
$parts = $this->getFuncParts($i, $tokens);
2828
if ($parts['name'] === null) $parts['name'] = 'data';
29-
if (!isset($this->functions[$parts['name']])) return true;
29+
if (!isset($this->functions[$parts['name']])) continue;
3030
if ($this->match($parts, $this->functions[$parts['name']], $element) === false) {
3131
return false;
3232
}

tests/BeforeAfterPseudoTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ public function testAfter() {
3030
$this->assertEquals($this->stripTabs('<div>TestAFTER</div>'), $this->stripTabs($template->output()->body));
3131
}
3232

33+
public function testConditionalAfterFalse() {
34+
$template = '
35+
<div>Test</div>
36+
';
37+
38+
$tss = 'div:[data()="test"]:after {content: "AFTER";}';
39+
40+
$template = new \Transphporm\Builder($template, $tss);
41+
42+
$this->assertEquals($this->stripTabs('<div>Test</div>'), $this->stripTabs($template->output("test1")->body));
43+
}
44+
45+
public function testConditionalAfterFalseCondition2nd() {
46+
$template = '
47+
<div>Test</div>
48+
';
49+
50+
$tss = 'div:after:[data()="test"] {content: "AFTER";}';
51+
52+
$template = new \Transphporm\Builder($template, $tss);
53+
54+
$this->assertEquals($this->stripTabs('<div>Test</div>'), $this->stripTabs($template->output("test1")->body));
55+
}
56+
3357
public function testOverrideAfter() {
3458
$xml = '<div>
3559
<span>Test</span>

tests/TransphpormTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ public function testContentModeAppendWithRepeat() {
19791979
<select class="status">
19801980
<option value="0">Default option</option>
19811981
</select>
1982-
XML;
1982+
XML;
19831983

19841984
$tss = <<<TSS
19851985
.status option {
@@ -1990,7 +1990,7 @@ public function testContentModeAppendWithRepeat() {
19901990
.status option:attr(value) {
19911991
content: key();
19921992
}
1993-
TSS;
1993+
TSS;
19941994

19951995
$data['status'] = [
19961996
1 => "Good",

0 commit comments

Comments
 (0)