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

s-bind 转换的 IIFE 语法在测试机上不支持 #9

Closed
l5oo00 opened this issue Nov 4, 2019 · 0 comments
Closed

s-bind 转换的 IIFE 语法在测试机上不支持 #9

l5oo00 opened this issue Nov 4, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@l5oo00
Copy link
Contributor

l5oo00 commented Nov 4, 2019

使用 s-bind 后转换出如下代码:

(function ($bindObj) use (&$html) {
    foreach ($bindObj as $key => $value) {
        switch ($key) {
            case "readonly":
            case "disabled":
            case "multiple":
                $html .= _::boolAttrFilter($key, _::escapeHTML($value));
                break;
            default:
                $html .= _::attrFilter($key, _::escapeHTML($value));
        }
    }
})(_::data($ctx, ["emptyAttrs"]));

搜了下, 看到这里的说明, 应该是 PHP 版本的问题, 改为以下代码即可:

call_user_func(function ($bindObj) use (&$html) {
    foreach ($bindObj as $key => $value) {
        switch ($key) {
            case "readonly":
            case "disabled":
            case "multiple":
                $html .= _::boolAttrFilter($key, _::escapeHTML($value));
                break;
            default:
                $html .= _::attrFilter($key, _::escapeHTML($value));
        }
    }
}, array(_::data($ctx, ["emptyAttrs"])));

目测应该是 ts2php 暂不支持, @harttle 看看是否在 san-ssr 里先支持了?

@harttle harttle added the bug Something isn't working label Nov 5, 2019
harttle pushed a commit that referenced this issue Nov 5, 2019
## [1.1.1](v1.1.0...v1.1.1) (2019-11-05)

### Bug Fixes

* remove IIFE for compatibility issues, see [#9](#9) ([b3707c2](b3707c2))
@harttle harttle closed this as completed Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants