Skip to content

Commit

Permalink
Don't abuse name attribute of svg elements
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
  • Loading branch information
MoonE committed Nov 3, 2024
1 parent 90f3c58 commit 83c83ea
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion js/src/table/gis_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ AJAX.registerOnload('table/gis_visualization.js', function () {
* Detect the mousemove event and show tooltips.
*/
$('.vector').on('mousemove', function (event) {
var contents = Functions.escapeHtml($(this).attr('name')).trim();
var contents = Functions.escapeHtml($(this).attr('data-label')).trim();
$('#tooltip').remove();
if (contents !== '') {
$('<div id="tooltip">' + contents + '</div>').css({
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function prepareRowAsPdf($spatial, ?string $label, $line_color, array $sc
public function prepareRowAsSvg($spatial, $label, $line_color, array $scale_data)
{
$line_options = [
'name' => $label,
'data-label' => $label,
'id' => $label . $this->getRandomId(),
'class' => 'linestring vector',
'fill' => 'none',
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function prepareRowAsPdf($spatial, ?string $label, $line_color, array $sc
public function prepareRowAsSvg($spatial, $label, $line_color, array $scale_data)
{
$line_options = [
'name' => $label,
'data-label' => $label,
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function prepareRowAsPdf(
public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_data)
{
$point_options = [
'name' => $label,
'data-label' => $label,
'class' => 'multipoint vector',
'fill' => 'white',
'stroke' => $point_color,
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function prepareRowAsPdf($spatial, ?string $label, $fill_color, array $sc
public function prepareRowAsSvg($spatial, $label, $fill_color, array $scale_data)
{
$polygon_options = [
'name' => $label,
'data-label' => $label,
'class' => 'multipolygon vector',
'stroke' => 'black',
'stroke-width' => 0.5,
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function prepareRowAsPdf(
public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_data)
{
$point_options = [
'name' => $label,
'data-label' => $label,
'id' => $label . $this->getRandomId(),
'class' => 'point vector',
'fill' => 'white',
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function prepareRowAsPdf($spatial, ?string $label, $fill_color, array $sc
public function prepareRowAsSvg($spatial, $label, $fill_color, array $scale_data)
{
$polygon_options = [
'name' => $label,
'data-label' => $label,
'id' => $label . $this->getRandomId(),
'class' => 'polygon vector',
'stroke' => 'black',
Expand Down
2 changes: 1 addition & 1 deletion test/classes/Gis/GisGeometryCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public static function providerForPrepareRowAsSvg(): array
'height' => 150,
],
'/^(<path d=" M 46, 268 L -4, 248 L 6, 208 L 66, 198 Z M 16,'
. ' 228 L 46, 224 L 36, 248 Z " name="svg" id="svg)(\d+)'
. ' 228 L 46, 224 L 36, 248 Z " data-label="svg" id="svg)(\d+)'
. '(" class="polygon vector" stroke="black" stroke-width="0.5"'
. ' fill="#B02EE0" fill-rule="evenodd" fill-opacity="0.8"\/>)$/',
],
Expand Down
2 changes: 1 addition & 1 deletion test/classes/Gis/GisLineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static function providerForPrepareRowAsSvg(): array
'height' => 150,
],
'/^(<polyline points="0,218 72,138 114,242 26,198 4,182 46,132 " '
. 'name="svg" id="svg)(\d+)(" class="linestring vector" fill="none" '
. 'data-label="svg" id="svg)(\d+)(" class="linestring vector" fill="none" '
. 'stroke="#B02EE0" stroke-width="2"\/>)$/',
],
];
Expand Down
4 changes: 2 additions & 2 deletions test/classes/Gis/GisMultiLineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ public static function providerForPrepareRowAsSvg(): array
'scale' => 2,
'height' => 150,
],
'/^(<polyline points="48,260 70,242 100,138 " name="svg" '
'/^(<polyline points="48,260 70,242 100,138 " data-label="svg" '
. 'class="linestring vector" fill="none" stroke="#B02EE0" '
. 'stroke-width="2" id="svg)(\d+)("\/><polyline points="48,268 10,'
. '242 332,182 " name="svg" class="linestring vector" fill="none" '
. '242 332,182 " data-label="svg" class="linestring vector" fill="none" '
. 'stroke="#B02EE0" stroke-width="2" id="svg)(\d+)("\/>)$/',
],
];
Expand Down
10 changes: 5 additions & 5 deletions test/classes/Gis/GisMultiPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ public static function providerForPrepareRowAsSvg(): array
'scale' => 2,
'height' => 150,
],
'/^(<circle cx="72" cy="138" r="3" name="svg" class="multipoint '
'/^(<circle cx="72" cy="138" r="3" data-label="svg" class="multipoint '
. 'vector" fill="white" stroke="#B02EE0" stroke-width="2" id="svg)'
. '(\d+)("\/><circle cx="114" cy="242" r="3" name="svg" class="mult'
. '(\d+)("\/><circle cx="114" cy="242" r="3" data-label="svg" class="mult'
. 'ipoint vector" fill="white" stroke="#B02EE0" stroke-width="2" id'
. '="svg)(\d+)("\/><circle cx="26" cy="198" r="3" name="svg" class='
. '="svg)(\d+)("\/><circle cx="26" cy="198" r="3" data-label="svg" class='
. '"multipoint vector" fill="white" stroke="#B02EE0" stroke-width='
. '"2" id="svg)(\d+)("\/><circle cx="4" cy="182" r="3" name="svg" '
. '"2" id="svg)(\d+)("\/><circle cx="4" cy="182" r="3" data-label="svg" '
. 'class="multipoint vector" fill="white" stroke="#B02EE0" stroke-'
. 'width="2" id="svg)(\d+)("\/><circle cx="46" cy="132" r="3" name='
. 'width="2" id="svg)(\d+)("\/><circle cx="46" cy="132" r="3" data-label='
. '"svg" class="multipoint vector" fill="white" stroke="#B02EE0" '
. 'stroke-width="2" id="svg)(\d+)("\/>)$/',
],
Expand Down
4 changes: 2 additions & 2 deletions test/classes/Gis/GisMultiPolygonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,10 @@ public static function providerForPrepareRowAsSvg(): array
'scale' => 2,
'height' => 150,
],
'/^(<path d=" M 248, 208 L 270, 122 L 8, 138 Z " name="svg" class="'
'/^(<path d=" M 248, 208 L 270, 122 L 8, 138 Z " data-label="svg" class="'
. 'multipolygon vector" stroke="black" stroke-width="0.5" fill="'
. '#B02EE0" fill-rule="evenodd" fill-opacity="0.8" id="svg)(\d+)'
. '("\/><path d=" M 186, 288 L 88, 248 L 132, 142 Z " name="svg" '
. '("\/><path d=" M 186, 288 L 88, 248 L 132, 142 Z " data-label="svg" '
. 'class="multipolygon vector" stroke="black" stroke-width="0.5" '
. 'fill="#B02EE0" fill-rule="evenodd" fill-opacity="0.8" id="svg)'
. '(\d+)("\/>)$/',
Expand Down
2 changes: 1 addition & 1 deletion test/classes/Gis/GisPolygonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public static function providerForPrepareRowAsSvg(): array
'scale' => 2,
'height' => 150,
],
'/^(<path d=" M 222, 288 L 22, 228 L 10, 162 Z " name="svg" '
'/^(<path d=" M 222, 288 L 22, 228 L 10, 162 Z " data-label="svg" '
. 'id="svg)(\d+)(" class="polygon vector" stroke="black" '
. 'stroke-width="0.5" fill="#B02EE0" fill-rule="evenodd" '
. 'fill-opacity="0.8"\/>)$/',
Expand Down

0 comments on commit 83c83ea

Please sign in to comment.