Skip to content

Commit

Permalink
Fix pseudo bug with after and conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
solleer committed Aug 30, 2020
1 parent ad9c666 commit 3eabb46
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Hook/PseudoMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function matches($element) {
foreach ($this->pseudo as $i => $tokens) {
$parts = $this->getFuncParts($i, $tokens);
if ($parts['name'] === null) $parts['name'] = 'data';
if (!isset($this->functions[$parts['name']])) return true;
if (!isset($this->functions[$parts['name']])) continue;
if ($this->match($parts, $this->functions[$parts['name']], $element) === false) {
return false;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/BeforeAfterPseudoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ public function testAfter() {
$this->assertEquals($this->stripTabs('<div>TestAFTER</div>'), $this->stripTabs($template->output()->body));
}

public function testConditionalAfterFalse() {
$template = '
<div>Test</div>
';

$tss = 'div:[data()="test"]:after {content: "AFTER";}';

$template = new \Transphporm\Builder($template, $tss);

$this->assertEquals($this->stripTabs('<div>Test</div>'), $this->stripTabs($template->output("test1")->body));
}

public function testConditionalAfterFalseCondition2nd() {
$template = '
<div>Test</div>
';

$tss = 'div:after:[data()="test"] {content: "AFTER";}';

$template = new \Transphporm\Builder($template, $tss);

$this->assertEquals($this->stripTabs('<div>Test</div>'), $this->stripTabs($template->output("test1")->body));
}

public function testOverrideAfter() {
$xml = '<div>
<span>Test</span>
Expand Down
4 changes: 2 additions & 2 deletions tests/TransphpormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ public function testContentModeAppendWithRepeat() {
<select class="status">
<option value="0">Default option</option>
</select>
XML;
XML;

$tss = <<<TSS
.status option {
Expand All @@ -1990,7 +1990,7 @@ public function testContentModeAppendWithRepeat() {
.status option:attr(value) {
content: key();
}
TSS;
TSS;

$data['status'] = [
1 => "Good",
Expand Down

0 comments on commit 3eabb46

Please sign in to comment.