From ec34c8694253861ac1c78554ffbe1ea1422418ac Mon Sep 17 00:00:00 2001
From: demike <derfler.michael@gmail.com>
Date: Thu, 30 Jan 2014 10:13:34 +0100
Subject: [PATCH 1/2] add the html5 search input

---
 lib/directive/ng_model.dart | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/directive/ng_model.dart b/lib/directive/ng_model.dart
index 32f5efb9b..fceb1da9c 100644
--- a/lib/directive/ng_model.dart
+++ b/lib/directive/ng_model.dart
@@ -189,6 +189,7 @@ class InputCheckboxDirective {
 @NgDirective(selector: 'input[type=url][ng-model]')
 @NgDirective(selector: 'input[type=email][ng-model]')
 @NgDirective(selector: 'input[type=number][ng-model]')
+@NgDirective(selector: 'input[type=search][ng-model]')
 class InputTextLikeDirective {
   final dom.Element inputElement;
   final NgModel ngModel;

From 161ef8f1fb6e78c2570034803c1600a18fc94ddb Mon Sep 17 00:00:00 2001
From: Michael Derfler <derfler.michael@gmail.com>
Date: Thu, 30 Jan 2014 11:27:32 +0100
Subject: [PATCH 2/2] add a test for input type="search"

---
 test/directive/ng_model_spec.dart | 64 +++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/test/directive/ng_model_spec.dart b/test/directive/ng_model_spec.dart
index 7df5bd05a..c6f91c472 100644
--- a/test/directive/ng_model_spec.dart
+++ b/test/directive/ng_model_spec.dart
@@ -135,6 +135,70 @@ describe('ng-model', () {
       expect(element.selectionEnd).toEqual(3);
     }));
   });
+  
+  describe('type="search"', () {
+    it('should update input value from model', inject(() {
+      _.compile('<input type="search" ng-model="model">');
+      _.rootScope.$digest();
+
+      expect((_.rootElement as dom.InputElement).value).toEqual('');
+
+      _.rootScope.$apply('model = "misko"');
+      expect((_.rootElement as dom.InputElement).value).toEqual('misko');
+    }));
+
+    it('should render null as the empty string', inject(() {
+      _.compile('<input type="search" ng-model="model">');
+      _.rootScope.$digest();
+
+      expect((_.rootElement as dom.InputElement).value).toEqual('');
+
+      _.rootScope.$apply('model = null');
+      expect((_.rootElement as dom.InputElement).value).toEqual('');
+    }));
+
+    it('should update model from the input value', inject(() {
+      _.compile('<input type="search" ng-model="model" probe="p">');
+      Probe probe = _.rootScope.p;
+      var ngModel = probe.directive(NgModel);
+      InputElement inputElement = probe.element;
+
+      inputElement.value = 'abc';
+      _.triggerEvent(inputElement, 'change');
+      expect(_.rootScope.model).toEqual('abc');
+
+      inputElement.value = 'def';
+      var input = probe.directive(InputTextLikeDirective);
+      input.processValue();
+      expect(_.rootScope.model).toEqual('def');
+    }));
+
+    it('should write to input only if value is different', inject(() {
+      var scope = _.rootScope;
+      var element = new dom.InputElement();
+      var model = new NgModel(scope, new NodeAttrs(new DivElement()), element, new NgNullForm());
+      dom.querySelector('body').append(element);
+      var input = new InputTextLikeDirective(element, model, scope);
+
+      element.value = 'abc';
+      element.selectionStart = 1;
+      element.selectionEnd = 2;
+
+      model.render('abc');
+
+      expect(element.value).toEqual('abc');
+      // No update.  selectionStart/End is unchanged.
+      expect(element.selectionStart).toEqual(1);
+      expect(element.selectionEnd).toEqual(2);
+
+      model.render('xyz');
+
+      // Value updated.  selectionStart/End changed.
+      expect(element.value).toEqual('xyz');
+      expect(element.selectionStart).toEqual(3);
+      expect(element.selectionEnd).toEqual(3);
+    }));
+  });
 
   describe('type="checkbox"', () {
     it('should update input value from model', inject((Scope scope) {