Skip to content

Commit dfeb7ff

Browse files
committed
Change data handling
1 parent 5979e06 commit dfeb7ff

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Compiler.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class Compiler
7777
protected $properties;
7878

7979
/**
80-
* @var Data[]
80+
* @var Data[]|null
8181
*/
82-
protected $data;
82+
protected $data = null;
8383

8484
/**
8585
* @var Pre[]
@@ -131,7 +131,6 @@ public function __construct(DOMDocument $document, LoggerInterface $logger)
131131
$this->components = [];
132132
$this->banner = [];
133133
$this->properties = [];
134-
$this->data = [];
135134
$this->pre = [];
136135
$this->rawBlocks = [];
137136

@@ -178,8 +177,10 @@ public function convert(): string
178177
if ($scriptElement) {
179178
$this->registerProperties($scriptElement);
180179
$this->insertDefaultValues();
181-
$this->registerData($scriptElement);
182-
$this->insertData();
180+
if ($this->data !== null) {
181+
$this->registerData($scriptElement);
182+
$this->insertData();
183+
}
183184
}
184185

185186
if ($twigBlocks->length) {
@@ -1220,6 +1221,13 @@ public function disableStyleInclude(): Compiler
12201221
return $this;
12211222
}
12221223

1224+
public function enableDataSupport(): Compiler
1225+
{
1226+
$this->data = [];
1227+
1228+
return $this;
1229+
}
1230+
12231231
public function setStyleBlockOutputType(int $outputType): Compiler
12241232
{
12251233
$this->styleBuilder->setOutputType($outputType);

tests/DataTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public function testData($html, $expected)
1818
{
1919
$compiler = $this->createCompiler($html);
2020

21+
$compiler->enableDataSupport();
22+
2123
$actual = $compiler->convert();
2224

2325
$this->assertEqualHtml($expected, $actual);

0 commit comments

Comments
 (0)