Code Monkey home page Code Monkey logo

canjs's Issues

const没有达到预期效果

const a = 1;a = 2;run()的时候不会报错,原因:
AssignmentExpressionOperatortraverseMap内部
"=": (value, v) => value instanceof MemberValue ? (value.obj[value.prop] = v) : (value.value = v),
应该写成:(value.set(v)),

varDeclare逻辑是不是有问题?

varDeclare中,在递归查找父作用域之后,不是应该定义到最终查找到的父作用域上吗,怎么还是赋给了this.declaration?

varDeclare (name, value) {
let scope = this
// 若当前作用域存在非函数类型的父级作用域时,就把变量定义到父级作用域
while (scope.parentScope && scope.type !== 'function') {
scope = scope.parentScope
}
this.declaration[name] = new SimpleValue(value, 'var')
return this.declaration[name]
}

还是有一些bug

比如逻辑操作符的短路求值策略;模块内的代码需要顺序执行,可能提前返回;UpdateExpression的变量类型不一定是Identifier;表达式优先要计算右值等等。运行大部分代码应该都可以了

es5 63行

es5.js 第63行是否有问题呢?
个人感觉 key.type === 'Identifier'的情况 可能是:
let a = 'key1'
let b = {
[a]: '123'
}

这里b中 [a]的key.type就是Identifier 所以key取值应该 也得从scope中获取

bug es5.js #53

MemberExpression (nodeIterator) { const obj = nodeIterator.traverse(nodeIterator.node.object) const name = nodeIterator.node.property.name return obj[name] }

53行应为:const name = getPropertyName(nodeIterator.node, nodeIterator)
否则,某些情况下会出错误

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.