Code Monkey home page Code Monkey logo

Comments (5)

fballiano avatar fballiano commented on August 22, 2024 1

it's just because in the templates there's gonna be something like

class="<?php if (aaa) echo aaaa ?> <?php if(something) echo bbb ?> anotherclass" which leads to those situations.

it's absolutely normal

from magento-lts.

kiatng avatar kiatng commented on August 22, 2024

According to stackoverflow referencing the various docs, it is valid to have leading and trailing spaces in class names.

from magento-lts.

ADDISON74 avatar ADDISON74 commented on August 22, 2024

Thank you @kiatng. From what I can see, those discussions are from 10 years ago.

Do you have any idea what would be the reason why the Magento team chose to use leading spaces? Could be a good idea to remove them just for visual effect?

from magento-lts.

kiatng avatar kiatng commented on August 22, 2024

As pointed by @fballiano, less clutter in the code.

from magento-lts.

ADDISON74 avatar ADDISON74 commented on August 22, 2024

The leading spaces are coming from this function

    /**
     * Get menu level HTML code
     *
     * @param array $menu
     * @param int $level
     * @return string
     */
    public function getMenuLevel($menu, $level = 0)
    {
        $html = '<ul ' . (!$level ? 'id="nav"' : '') . '>' . PHP_EOL;
        foreach ($menu as $item) {
            if ((empty($item['url']) || ($item['url'] == '#')) && empty($item['children'])) {
                continue; // for example hide System/Tools when empty
            }
            $html .= '<li ' . (!empty($item['children']) ? 'onmouseover="Element.addClassName(this,\'over\')" '
                . 'onmouseout="Element.removeClassName(this,\'over\')"' : '') . ' class="'
                . (!$level && !empty($item['active']) ? ' active' : '') . ' '
                . (!empty($item['children']) ? ' parent' : '')
                . (!empty($level) && !empty($item['last']) ? ' last' : '')
                . ' level' . $level . '"> <a href="' . $item['url'] . '" '
                . (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
                . (!empty($item['target']) ? 'target="' . $item['target'] . '"' : '') . ' '
                . (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
                . (!empty($item['active']) ? 'active' : '') . '"><span>'
                . $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;
            if (!empty($item['children'])) {
                $html .= $this->getMenuLevel($item['children'], $level + 1);
            }
            $html .= '</li>' . PHP_EOL;
        }
        $html .= '</ul>' . PHP_EOL;

        return $html;
    }

Considering that it is not an issue in the source code, I close the report.

from magento-lts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.