Skip to content

Commit

Permalink
Merge pull request #272 from creative-commoners/pulls/2/htmldiff-name…
Browse files Browse the repository at this point in the history
…-change

Failed JS test steps are unrelated to these changes
  • Loading branch information
sabina-talipova authored Feb 8, 2023
2 parents cb31759 + 90ee112 commit 90bc363
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Forms/DiffField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use SilverStripe\Forms\HTMLEditor\HTMLEditorField_Readonly;
use SilverStripe\Forms\HTMLReadonlyField;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\View\Parsers\Diff;
use SilverStripe\View\Parsers\HtmlDiff;

/**
* This form field is both a field object in it's own right, and a decorator for another field type.
Expand Down Expand Up @@ -71,7 +71,8 @@ public function Value()
$newValue = strip_tags($emptyPlaceholder);
}
}
return Diff::compareHTML($oldValue, $newValue, $escape);

return HtmlDiff::compareHtml($oldValue ?? '', $newValue ?? '', $escape);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Forms/DiffFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testScalarValuesAreDiffed()
$diffField->setComparisonField($newField);
$diffField->setValue('old');

$this->assertMatchesRegularExpression('/^<ins>new<\/ins> *<del>old<\/del>$/', $diffField->Value());
$this->assertMatchesRegularExpression('/^<del>old<\/del> *<ins>new<\/ins>$/', $diffField->Value());
}

/**
Expand Down Expand Up @@ -90,14 +90,14 @@ public function provideEscaping()
ReadonlyField::class,
'',
'Something',
'<ins>$emptyPlaceholderNoTags</ins> <del>Something</del>',
'<del>Something</del> <ins>$emptyPlaceholderNoTags</ins>',
'No value is escaped without tags removed when value added'
],
[
ReadonlyField::class,
'Something',
'',
'<ins>Something</ins> <del>$emptyPlaceholderNoTags</del>',
'<del>$emptyPlaceholderNoTags</del> <ins>Something</ins>',
'No value is escaped without tags removed when value removed'
],
];
Expand Down

0 comments on commit 90bc363

Please sign in to comment.