From 813f3b03dbaa53acb9bbe8428a6c5137a26795d6 Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Tue, 10 Nov 2015 23:43:36 -0800 Subject: [PATCH] [React.14] Add checkedLink/valueLink to HTMLAttributes for LinkedStateMixin --- react/react-addons-linked-state-mixin.d.ts | 5 +++++ react/react-tests.ts | 21 +++++++++++++++++++-- react/react.d.ts | 7 +++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts index 5cee5fd5d..d9e5b7beb 100644 --- a/react/react-addons-linked-state-mixin.d.ts +++ b/react/react-addons-linked-state-mixin.d.ts @@ -14,6 +14,11 @@ declare namespace __React { interface LinkedStateMixin extends Mixin { linkState(key: string): ReactLink; } + + interface HTMLAttributes { + checkedLink?: ReactLink; + valueLink?: ReactLink; + } namespace __Addons { export var LinkedStateMixin: LinkedStateMixin; diff --git a/react/react-tests.ts b/react/react-tests.ts index 8349aa3c4..d0f9ae146 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -466,8 +466,25 @@ React.createFactory(CSSTransitionGroup)({ // LinkedStateMixin addon // -------------------------------------------------------------------------- React.createClass({ - mixins: [LinkedStateMixin], - render: function() { return React.DOM.div(null) } + mixins: [LinkedStateMixin], + getInitialState: function() { + return { + isChecked: false, + message: "hello!" + }; + }, + render: function() { + return React.DOM.div(null, + React.DOM.input({ + type: "checkbox", + checkedLink: this.linkState("isChecked") + }), + React.DOM.input({ + type: "text", + valueLink: this.linkState("message") + }) + ); + } }); // diff --git a/react/react.d.ts b/react/react.d.ts index 115c9fa9b..e3d0f43f7 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -324,8 +324,6 @@ declare namespace __React { } interface HTMLProps extends HTMLAttributes, Props { - defaultChecked?: boolean; - defaultValue?: string | string[]; } interface SVGProps extends SVGAttributes, Props { @@ -454,6 +452,11 @@ declare namespace __React { } interface HTMLAttributes extends DOMAttributes { + // React-specific Attributes + defaultChecked?: boolean; + defaultValue?: string | string[]; + + // Standard HTML Attributes accept?: string; acceptCharset?: string; accessKey?: string;