Skip to content

Commit fcebadd

Browse files
committed
Change style builder
1 parent 2c36d37 commit fcebadd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Utils/StyleBuilder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
class StyleBuilder
1313
{
14+
private const STYLE_NO = 0;
15+
private const STYLE_SCOPED = 1;
16+
private const STYLE = 2;
17+
private const STYLE_ALL = 3;
18+
1419
/**
1520
* @var ScssCompiler|null
1621
*/
@@ -31,13 +36,19 @@ class StyleBuilder
3136
*/
3237
private $scopedAttribute;
3338

39+
/**
40+
* @var int
41+
*/
42+
private $outputType;
43+
3444
/**
3545
* StyleBuilder constructor.
3646
*
3747
* @throws Exception
3848
*/
3949
public function __construct()
4050
{
51+
$this->outputType = self::STYLE_ALL;
4152
$this->scopedAttribute = 'data-v-' . substr(md5(Uuid::uuid4()->toString()), 0, 8);
4253
$this->hasScoped = false;
4354
}
@@ -51,6 +62,11 @@ public function compile($styleElement): ?string
5162
return null;
5263
}
5364

65+
if (($styleElement->hasAttribute('scoped') && !($this->outputType & self::STYLE_SCOPED))
66+
|| (!$styleElement->hasAttribute('scoped') && !($this->outputType & self::STYLE))) {
67+
return null;
68+
}
69+
5470
if (
5571
!$this->scssCompiler instanceof ScssCompiler
5672
&& $styleElement->hasAttribute('lang')

0 commit comments

Comments
 (0)