<commit_before>// Copyright (c) 2014, the Liquid project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of liquid.vdom;

/// Creates a new [TextInput] element.
VTextInput textInput({
  Object key,
  String value,
  String placeholder,
  bool autofocus,
  String id,
  Map<String, String> attributes,
  List<String> classes,
  Map<String, String> styles}) {

  return new VTextInput(
      key: key,
      value: value,
      placeholder: placeholder,
      autofocus: autofocus,
      id: id,
      attributes: attributes,
      classes: classes,
      styles: styles);
}

/// Virtual DOM Text Input Element
class VTextInput extends VElementBase<html.InputElement> {
  final String _value;
  final String placeholder;
  final bool autofocus;

  String get value => ref.value;

  VTextInput({
    Object key,
    String value,
    this.placeholder,
    this.autofocus,
    String id,
    Map<String, String> attributes,
    List<String> classes,
    Map<String, String> styles})
    : _value = value,
      super(key, null, id, attributes, classes, styles);

  void create(Context context) { ref = new html.InputElement(type: 'text'); }

  void render(Context context) {
    super.render(context);
    if (_value != null) {
      ref.value = _value;
    }
    if (placeholder != null) {
      ref.placeholder = placeholder;
    }
    if (autofocus != null) {
      ref.autofocus = true;
    }
  }

  void update(VTextInput other, Context context) {
    super.update(other, context);
    if (other._value != null && ref.value != other._value) {
      ref.value = other._value;
    }
    if (other.placeholder != placeholder) {
      ref.placeholder = other.placeholder;
    }
    // no need to update autofocus when element is already created.
  }
}
<commit_msg>Fix autofocus property in VTextInput node<commit_after>// Copyright (c) 2014, the Liquid project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of liquid.vdom;

/// Creates a new [TextInput] element.
VTextInput textInput({
  Object key,
  String value,
  String placeholder,
  bool autofocus,
  String id,
  Map<String, String> attributes,
  List<String> classes,
  Map<String, String> styles}) {

  return new VTextInput(
      key: key,
      value: value,
      placeholder: placeholder,
      autofocus: autofocus,
      id: id,
      attributes: attributes,
      classes: classes,
      styles: styles);
}

/// Virtual DOM Text Input Element
class VTextInput extends VElementBase<html.InputElement> {
  final String _value;
  final String placeholder;
  final bool autofocus;

  String get value => ref.value;

  VTextInput({
    Object key,
    String value,
    this.placeholder,
    this.autofocus,
    String id,
    Map<String, String> attributes,
    List<String> classes,
    Map<String, String> styles})
    : _value = value,
      super(key, null, id, attributes, classes, styles);

  void create(Context context) { ref = new html.InputElement(type: 'text'); }

  void render(Context context) {
    super.render(context);
    if (_value != null) {
      ref.value = _value;
    }
    if (placeholder != null) {
      ref.placeholder = placeholder;
    }
    if (autofocus != null) {
      ref.autofocus = autofocus;
    }
  }

  void update(VTextInput other, Context context) {
    super.update(other, context);
    if (other._value != null && ref.value != other._value) {
      ref.value = other._value;
    }
    if (other.placeholder != placeholder) {
      ref.placeholder = other.placeholder;
    }
    // no need to update autofocus when element is already created.
  }
}

{'fraction_non_alphanumeric': 0.10416121434179534, 'fraction_numerical': 0.002093692750588851, 'mean_word_length': 2.9079754601226995, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3613897', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1125, 'n_words': 377}