From d7404c349b69810867145f8f3e447023e1eec0ef Mon Sep 17 00:00:00 2001 From: Hao Sun Date: Wed, 15 Feb 2023 15:02:34 +0800 Subject: [PATCH] * zin: refactor --- zin/core/h.class.php | 7 +++++++ zin/core/props.class.php | 4 ++-- zin/core/wg.class.php | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/zin/core/h.class.php b/zin/core/h.class.php index db1daabf09..97334171b8 100644 --- a/zin/core/h.class.php +++ b/zin/core/h.class.php @@ -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()); diff --git a/zin/core/props.class.php b/zin/core/props.class.php index 3adfe19b2f..e5cc43587d 100755 --- a/zin/core/props.class.php +++ b/zin/core/props.class.php @@ -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; } diff --git a/zin/core/wg.class.php b/zin/core/wg.class.php index dac42ed0f3..837a081c05 100644 --- a/zin/core/wg.class.php +++ b/zin/core/wg.class.php @@ -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();