diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 344ac6c85e27..350b97fca346 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -865,7 +865,7 @@ void Node::enumerateChildren(const std::string &name, const std::functiondoEnumerateRecursive(this, newName, callback); + target->doEnumerateRecursive(target, newName, callback); } else { diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 88151ed33634..978a787d755e 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -1384,14 +1384,14 @@ void NodeNameTest::test(float dt) // search from parent // name is xxx/.. i = 0; - parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool { ++i; return true; }); CCAssert(i == 1, ""); i = 0; - parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool { ++i; return false; }); @@ -1430,11 +1430,11 @@ void NodeNameTest::test(float dt) CCAssert(i == 1, ""); i = 0; - parent->enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { + parent->getChildByName("node1")->enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { ++i; return false; }); - CCAssert(i == 100, ""); + CCAssert(i == 110, ""); // utils::findChildren()