Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixbug: for in 改成 for of #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cocos-creator/Poco/Cocos2dxNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Node.prototype.getChildren = function () {
var nodeChildren = cgetter(this.node, 'children')
if (nodeChildren) {
children = []
for (var i in nodeChildren) {
var child = nodeChildren[i]
for (let child of nodeChildren) {
children.push(new Node(child, this.screenWidth, this.screenHeight))
}
}
Expand Down Expand Up @@ -84,8 +83,7 @@ Node.prototype.getAttr = function (attrName) {
return cgetter(this.node, 'name') || '<no-name>'
}
else if (attrName === 'text') {
for (var i in this.node._components) {
var c = this.node._components[i]
for (var c of this.node._components) {
if (c.string !== undefined) {
return c.string
}
Expand Down
3 changes: 1 addition & 2 deletions cocos-creator/Poco/sdk/AbstractDumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ AbstractDumper.prototype.dumpHierarchyImpl = function (node, onlyVisibleNode) {
var result = {}
var children = []
var nodeChildren = node.getChildren()
for (var i in nodeChildren) {
var child = nodeChildren[i]
for (var child of nodeChildren) {
if (!onlyVisibleNode || (payload['visible'] || child.getAttr('visible'))) {
children.push(this.dumpHierarchyImpl(child, onlyVisibleNode))
}
Expand Down
3 changes: 1 addition & 2 deletions cocos-creator/Poco/sdk/AbstractNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ AbstractNode.prototype.enumerateAttrs = function () {
// :rettype: Iterable<string, ValueType>
var ret = {}
var allAttrNames = this.getAvailableAttributeNames()
for (var i in allAttrNames) {
var attrName = allAttrNames[i]
for (var attrName of allAttrNames) {
var attrVal = this.getAttr(attrName)
if (attrVal !== undefined) {
ret[attrName] = attrVal
Expand Down
6 changes: 2 additions & 4 deletions cocos-creator/Poco/sdk/DefaultMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ DefaultMatcher.prototype.match = function (cond, node) {

// 条件匹配
if (op === 'and') {
for (var i in args) {
var arg = args[i]
for (var arg of args) {
if (!this.match(arg, node)) {
return false
}
Expand All @@ -49,8 +48,7 @@ DefaultMatcher.prototype.match = function (cond, node) {
}

if (op === 'or') {
for (var i in args) {
var arg = args[i]
for (var arg of args) {
if (this.match(arg, node)) {
return true
}
Expand Down
9 changes: 3 additions & 6 deletions cocos-creator/Poco/sdk/Selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Selector.prototype.selectImpl = function (cond, multiple, root, maxDepth, onlyVi

if (op === '>' || op === '/') {
var parents = [root]
for (var index in args) {
index = parseInt(index)
for(let index = 0;index < arg.length; index++) {
var arg = args[index]
var midResult = []
for (var j in parents) {
Expand All @@ -59,8 +58,7 @@ Selector.prototype.selectImpl = function (cond, multiple, root, maxDepth, onlyVi
var query1 = args[0]
var query2 = args[1]
var result1 = this.selectImpl(query1, multiple, root, maxDepth, onlyVisibleNode, includeRoot)
for (var index in result1) {
var n = result1[index]
for (var n of result1) {
var sibling_result = this.selectImpl(query2, multiple, n.getParent(), 1, onlyVisibleNode, includeRoot)
for (var k in sibling_result) {
if (result.indexOf(sibling_result[k]) < 0) {
Expand Down Expand Up @@ -118,8 +116,7 @@ Selector.prototype._selectTraverse = function (cond, node, outResult, multiple,
maxDepth -= 1

var children = node.getChildren()
for (var i in node.getChildren()) {
var child = children[i]
for (var child of children) {
var finished = this._selectTraverse(cond, child, outResult, multiple, maxDepth, onlyVisibleNode, true)
if (finished) {
return true
Expand Down