FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=19063&edit=1

ID: 19063
Updated by: loki_angel@mail.ru
Reported By: loki_angel at mail dot ru
Summary: error in JS _clearErrors()
Status: Open
Type: Bug
Package: HTML_QuickForm2
-Operating System:
+Operating System: irrelevant
Package Version: 0.6.1
-PHP Version: 5.2.9
+PHP Version: irrelevant
Roadmap Versions:
New Comment:

-Operating System:
+Operating System: irrelevant
-PHP Version: 5.2.9
+PHP Version: irrelevant



Previous Comments:
------------------------------------------------------------------------

[2011-11-21 12:02:37] loki

Description:
------------
function _clearErrors(element)
{
var spans = element.getElementsByTagName('span');
for (var i = 0, span; span = spans[i]; i++) {
if (qf.classes.has(span, 'error')) {
span.parentNode.removeChild(span);
}
}
};

function has followed errors:

1. after remove "span" from "spans", "spans" becomes one element less.
So indexes sifts. Iterator "i" still rise and some spans are skips.

2. function does not remove the "error" class of the parent element.
It's problem for chained rules.

------------------------------------------------------------------------

Search Discussions

  • Loki_angel at Nov 22, 2011 at 10:43 am
    Edit report at http://pear.php.net/bugs/bug.php?id=19063&edit=1

    ID: 19063
    Comment by: loki_angel@mail.ru
    Reported By: loki_angel at mail dot ru
    Summary: error in JS _clearErrors()
    Status: Open
    Type: Bug
    Package: HTML_QuickForm2
    Operating System: irrelevant
    Package Version: 0.6.1
    PHP Version: irrelevant
    Roadmap Versions:
    New Comment:

    possible solution:
    function _clearErrors(element)
    {
    var spans = element.getElementsByTagName('span');
    for (var i = 0, span; span = spans[i]; i++) {
    if (qf.classes.has(span, 'error')) {
    qf.classes.remove(span.parentNode, ['error', 'valid']);
    span.parentNode.removeChild(span);
    i--;
    }
    }
    };


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-11-21 14:02:51] loki

    -Operating System:
    +Operating System: irrelevant
    -PHP Version: 5.2.9
    +PHP Version: irrelevant


    ------------------------------------------------------------------------

    [2011-11-21 12:02:37] loki

    Description:
    ------------
    function _clearErrors(element)
    {
    var spans = element.getElementsByTagName('span');
    for (var i = 0, span; span = spans[i]; i++) {
    if (qf.classes.has(span, 'error')) {
    span.parentNode.removeChild(span);
    }
    }
    };

    function has followed errors:

    1. after remove "span" from "spans", "spans" becomes one element less.
    So indexes sifts. Iterator "i" still rise and some spans are skips.

    2. function does not remove the "error" class of the parent element.
    It's problem for chained rules.

    ------------------------------------------------------------------------
  • Borz_off at Nov 22, 2011 at 4:46 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=19063&edit=1

    ID: 19063
    Updated by: borz_off@cs.msu.su
    Reported By: loki_angel at mail dot ru
    Summary: error in JS _clearErrors()
    -Status: Open
    +Status: Analyzed
    Type: Bug
    Package: HTML_QuickForm2
    Operating System: irrelevant
    Package Version: 0.6.1
    PHP Version: irrelevant
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Analyzed
    1. Confirmed, getElementsByTagName() returns NodeList and that indeed
    reflects changes in the DOM tree:
    http://www.w3schools.com/dom/dom_nodelist.asp

    2. Can you please provide a test script where this matters? AFAIR,
    _clearErrors() is run immediately before validation and "error" /
    "valid" classes are set / reset there.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-11-22 11:42:36] loki

    possible solution:
    function _clearErrors(element)
    {
    var spans = element.getElementsByTagName('span');
    for (var i = 0, span; span = spans[i]; i++) {
    if (qf.classes.has(span, 'error')) {
    qf.classes.remove(span.parentNode, ['error', 'valid']);
    span.parentNode.removeChild(span);
    i--;
    }
    }
    };

    ------------------------------------------------------------------------

    [2011-11-21 14:02:51] loki

    -Operating System:
    +Operating System: irrelevant
    -PHP Version: 5.2.9
    +PHP Version: irrelevant


    ------------------------------------------------------------------------

    [2011-11-21 12:02:37] loki

    Description:
    ------------
    function _clearErrors(element)
    {
    var spans = element.getElementsByTagName('span');
    for (var i = 0, span; span = spans[i]; i++) {
    if (qf.classes.has(span, 'error')) {
    span.parentNode.removeChild(span);
    }
    }
    };

    function has followed errors:

    1. after remove "span" from "spans", "spans" becomes one element less.
    So indexes sifts. Iterator "i" still rise and some spans are skips.

    2. function does not remove the "error" class of the parent element.
    It's problem for chained rules.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedNov 21, '11 at 1:03p
activeNov 22, '11 at 4:46p
posts3
users3
websitepear.php.net

People

Translate

site design / logo © 2022 Grokbase