From 39a3ef818368665d69a49fc896c1fec70088a820 Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 21 Jul 2022 19:29:43 +0200 Subject: [PATCH] rename parent_node to parentId, as parentNode is already a DOM property --- api/etemplate.php | 41 +++++++++++++------------ api/js/etemplate/Et2Widget/Et2Widget.ts | 4 +-- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/api/etemplate.php b/api/etemplate.php index 1b6dbbbc6e..a5c1025106 100644 --- a/api/etemplate.php +++ b/api/etemplate.php @@ -346,27 +346,28 @@ function send_template() (substr($matches[ADD_ET2_PREFIX_LAST_GROUP], -1) === '/' ? substr($matches[ADD_ET2_PREFIX_LAST_GROUP], 0, -1) . '>'; }, $str); - - // change all attribute-names of new et2-* widgets to camelCase - $str = preg_replace_callback('/]+)>/', static function(array $matches) - { - preg_match_all('/(^| )([a-z\d_-]+)="([^"]+)"/i', $matches[2], $attrs, PREG_PATTERN_ORDER); - $attrs = array_combine($attrs[2], $attrs[3]); - - foreach($attrs as $name => $value) - { - if (count($parts = preg_split('/[_-]/', $name)) > 1) - { - $attrs[array_shift($parts).implode('', array_map('ucfirst', $parts))] = $value; - unset($attrs[$name]); - } - } - $ret = str_replace($matches[2], implode(' ', array_map(static function ($name, $value) { - return $name . '="' . $value . '"'; - }, array_keys($attrs), $attrs)).(substr($matches[2], -1) === '/' ? '/' : ''), $matches[0]); - return $ret; - }, $str); } + // change all attribute-names of new et2-* widgets to camelCase + $str = preg_replace_callback('/]+)>/', static function(array $matches) + { + preg_match_all('/(^| )([a-z\d_-]+)="([^"]+)"/i', $matches[2], $attrs, PREG_PATTERN_ORDER); + $attrs = array_combine($attrs[2], $attrs[3]); + + foreach($attrs as $name => $value) + { + if (count($parts = preg_split('/[_-]/', $name)) > 1) + { + if ($name === 'parent_node') $parts[1] = 'Id'; // we can not use DOM property parentNode --> parentId + $attrs[array_shift($parts).implode('', array_map('ucfirst', $parts))] = $value; + unset($attrs[$name]); + } + } + $ret = str_replace($matches[2], implode(' ', array_map(static function ($name, $value) { + return $name . '="' . $value . '"'; + }, array_keys($attrs), $attrs)).(substr($matches[2], -1) === '/' ? '/' : ''), $matches[0]); + return $ret; + }, $str); + $processing = microtime(true); if (isset($cache) && (file_exists($cache_dir = dirname($cache)) || mkdir($cache_dir, 0755, true) || is_dir($cache_dir))) diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index c90c9c69d0..191b20ce47 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -144,7 +144,7 @@ const Et2WidgetMixin = (superClass : T) => * Widget ID of another node to insert this node into instead of the normal location * This isn't a normal property... */ - parent_node: {type: String}, + parentId: {type: String}, /** * Tooltip which is shown for this element on hover @@ -901,7 +901,7 @@ const Et2WidgetMixin = (superClass : T) => * * @param {string} parent */ - set parent_node(parent : string | Element) + set parentId(parent : string | Element) { if(typeof parent === "string") {