与famo.us的属性

sda*_*day 3 famo.us

创建InputSurface时,我无法使用各种属性,例如autofocus或maxLength.

this.email = new InputSurface({
        classes: ['login-form'],
        content: '',
        size: [300, 40],
        placeholder:'email',
        properties: {
            autofocus:'autofocus',
            maxLength:'5',
            textAlign: 'left'
        }
    });
Run Code Online (Sandbox Code Playgroud)

渲染的div缺少我设置的属性.

<input class="famous-surface login-form" placeholder="email" type="text" name="" style="-webkit-transform-origin: 0% 0%; opacity: 0.999999; -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 614.5, 273.5, 0, 1); text-align: left; width: 300px; height: 40px;">
Run Code Online (Sandbox Code Playgroud)

显然,5的电子邮件的maxLength是愚蠢的,但我只是想看看它是否可行,但我可以继续输入超过5,并且当表面渲染时,它没有聚焦.有任何想法吗?我查看了示例/演示,但找不到使用这些属性或自动对焦的输入表面的示例/演示.

sda*_*day 8

正如dmvaldman所说,这还不是一个功能,所以下面的黑客将使它成为一个功能.

显然不是长期解决方案,但我在InputSurface.js中添加了几行,现在这些属性被消耗掉了.

首先,我添加了分配_attributes的单行

function InputSurface(options) {
    this._placeholder = options.placeholder || '';
    this._value       = options.value || '';
    this._type        = options.type || 'text';
    this._name        = options.name || '';
    this._attributes = options.attributes || '';

    Surface.apply(this, arguments);
    this.on('click', this.focus.bind(this));
}
Run Code Online (Sandbox Code Playgroud)

然后我添加了for循环消费部分进行部署.

InputSurface.prototype.deploy = function deploy(target) {
    if (this._placeholder !== '') target.placeholder = this._placeholder;
    target.value = this._value;
    target.type = this._type;
    target.name = this._name;

    for (var n in this._attributes) {
        target[n] = this._attributes[n];
    }
};
Run Code Online (Sandbox Code Playgroud)

所以现在我可以做到以下几点:

    this.email = new InputSurface({
        classes: ['login-form'],
        content: '',
        size: [300, 40],
        placeholder:'email',
        attributes: {
            autofocus:'autofocus',
            maxLength:5
        }
    });
Run Code Online (Sandbox Code Playgroud)

再一次,我意识到修改核心代码不是一个长期的解决方案,我现在只需要一些东西,直到某人有一个"官方"的答案,这对我有用.