Conversation
|
这个很难做到正确的处理吧,regular 没有类似 vue 和 mobx 使用链路的追踪,很难得知这个值是否被用到吧。 |
|
可以做到,之前是我实现有问题 |
实现思路(更新)以下面的代码为例 {#inc this.$body with { foo: bar }}通过 extra 传入 $scope(基本思路)
|
<Scope>
{ $scope.item }
</Scope>
|
|
代指用了scoped include的组件 |
|
所以嵌套的那种,是没有获取外层$scope的能力的吧? |
|
如果指定不同的名字可以获取的,但是如果是默认的$scope,会被就近的那个组件覆盖 比如
<Parent $scope="parentScope">
<Child>
{ parentScope.item }
{ $scope.item }
</Child>
</Parent>
<Parent>
<Child>
{ $scope.item }
</Child>
</Parent> |
dist/regular.js
Outdated
| // {{~}} | ||
| op.inc = op.include = function(){ | ||
| var content = this.expression(); | ||
| var first = this.ll(1); |
There was a problem hiding this comment.
这个貌似有问题,是假设了 使用 this.$body 就是fragment类型 么? 理论上使用this.$body 和使用 其他 fragment类型的变量是一样的处理方式。 比如 <Scope title = {~ <div> {title} </div>} /> 配和 {#inc title}
There was a problem hiding this comment.
There was a problem hiding this comment.
是指这里的一堆if判断嘛,这个是为了限制复杂表达式的
比如{#inc x + y with { item: item }},复杂表达式x + y不允许和scoped include一起使用
There was a problem hiding this comment.
这段if/else对后面的scoped include实现没帮助的,只影响下面的this.error,去掉也没事,目前的实现已经支持 {#inc title} 这种类型的fragment了
There was a problem hiding this comment.
可以精简一次pr的内容,即使有坑,但之前也是没这个逻辑的,可以换个pr处理。
|
合之前我再补充下测试用例吧 |
|
done,测试用例已加 |
|
scope的功能不打算加入master吗? |
等我晚上回去先解决一下代码冲突 |
Closes #196
测试结果
新的测试用例
scoped include 相关的用例待编写,稍后补上
实现思路
{#inc this.$body with { foo: bar }}$watch
this.$body和 表达式{ foo: bar },在变动时,通过 extra 传入 $scope问题
但是有一个问题,由于不知道用的时候是否使用了foo,导致一些场景下存在性能问题
比如:
{#list items as item} {#inc this.$body with { foo: bar, item: item, index: item_index }} {/list}这种情况下,虽然未使用
foo,但我们无法得知,当 bar 变化时,导致{ foo: bar, item: item, index: item_index }发生变化,代码会重新执行ctx.$compile编译 this.$body,将整个 this.$body 替换掉,但这更新是多余的,不知道是不是有更好的实现方式可以避开这个问题