* zin: refactor

This commit is contained in:
Hao Sun
2023-02-15 15:02:34 +08:00
parent df05e4c8bc
commit d7404c349b
3 changed files with 22 additions and 5 deletions
+7
View File
@@ -39,6 +39,13 @@ class h extends wg
return array($this->buildTagBegin(), parent::build(), $this->buildTagEnd());
}
protected function toJsonData()
{
$data = parent::toJsonData();
$data['type'] = 'h:' . $this->getTagName();
return $data;
}
protected function getPropsStr()
{
$skipProps = array_keys(static::getDefinedProps());
+2 -2
View File
@@ -166,8 +166,8 @@ class props extends \zin\utils\dataset
public function toJsonData()
{
$data = $this->data;
$data['style'] = $this->style->data;
$data['class'] = $this->class->toStr();
if(!empty($this->style->data)) $data['style'] = $this->style->data;
if(!empty($this->class->list)) $data['class'] = $this->class->toStr();
return $data;
}
+13 -3
View File
@@ -27,8 +27,6 @@ class wg
protected static $defineBlocks = NULL;
private static $definedPropsMap = array();
/**
* The props of the element
*
@@ -270,9 +268,19 @@ class wg
$value[$index] = $child->toJsonData();
}
}
$data['blocks'][$key] = $value;
if($key === 'children')
{
unset($data['blocks'][$key]);
$data['children'] = $value;
}
else
{
$data['blocks'][$key] = $value;
}
}
if(empty($data['blocks'])) unset($data['blocks']);
return $data;
}
@@ -287,6 +295,8 @@ class wg
return $defaultProps;
}
private static $definedPropsMap = array();
protected static function getDefinedProps()
{
$name = get_called_class();