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

Deprecate deprecated KeyboardEvent fields #711

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ object CallbackOption {
implicit def fromCallback(c: Callback): CallbackOption[Unit] =
c.toCBO

def keySwitch[A](e : ReactKeyboardEvent,
altKey : Boolean = false,
ctrlKey : Boolean = false,
metaKey : Boolean = false,
shiftKey: Boolean = false)
(switch : PartialFunction[String, CallbackTo[A]]): CallbackOption[A] =
keyEventSwitch(e, e.key, altKey, ctrlKey, metaKey, shiftKey)(switch)

@deprecated("Use .keySwitch instead. keyCode is officially deprecated.", "1.7.0")
def keyCodeSwitch[A](e : ReactKeyboardEvent,
altKey : Boolean = false,
ctrlKey : Boolean = false,
Expand Down
38 changes: 36 additions & 2 deletions core/src/main/scala/japgolly/scalajs/react/raw/events.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,46 @@ trait SyntheticKeyboardEvent[+DOMEventTarget <: dom.Node] extends SyntheticUIEve
/** See org.scalajs.dom.extensions.KeyValue */
val key: String = js.native

/** printable keys (letters, numbers, symbols) */
/** Non-standard.
* This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it
* will not work for every user. There may also be large incompatibilities between implementations and the behavior
* may change in the future.
*
* Deprecated. This feature is no longer recommended.
* Though some browsers might still support it, it may have already been removed from the relevant web standards, may
* be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update
* existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware
* that this feature may cease to work at any time.
*
* The charCode read-only property of the KeyboardEvent interface returns the Unicode value of a character key
* pressed during a keypress event.
*/
@deprecated("Use .key instead. See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode", "1.7.0")
val charCode: Int = js.native

/** non-printable keys (modifiers, arrow keys, tab, esc) */
/** Deprecated. This feature is no longer recommended.
* Though some browsers might still support it, it may have already been removed from the relevant web standards, may
* be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update
* existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware
* that this feature may cease to work at any time.
*
* The deprecated KeyboardEvent.keyCode read-only property represents a system and implementation dependent numerical
* code identifying the unmodified value of the pressed key. This is usually the decimal ASCII (RFC 20) or Windows
* 1252 code corresponding to the key. If the key can't be identified, this value is 0.
*/
@deprecated("See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode", "1.7.0")
val keyCode: Int = js.native

/** Deprecated. This feature is no longer recommended.
* Though some browsers might still support it, it may have already been removed from the relevant web standards, may
* be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update
* existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware
* that this feature may cease to work at any time.
*
* The which read-only property of the KeyboardEvent interface returns the numeric keyCode of the key pressed, or the
* character code (charCode) for an alphanumeric key pressed.
*/
@deprecated("See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which", "1.7.0")
val which: Int = js.native
}

Expand Down
9 changes: 9 additions & 0 deletions doc/changelog/1.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@
* `getDerivedStateFromProps[S](f: P => S)` can now be used as step 2 in the component builder, instead of calling one of the `initialState` methods and then `getDerivedStateFromProps` again later
* `getDerivedStateFromPropsAndState[S](f: (P, Option[S]) => S)` can now be used as step 2 in the component builder, instead of calling one of the `initialState` methods and then `getDerivedStateFromProps` again later

* Deprecate `KeyboardEvent` fields:
* `.charCode`
* `.keyCode`
* `.which`

* In `CallbackOption`:
* deprecate `keyCodeSwitch`
* add `keySwitch`

* Upgrade to React 16.13.1
* Add `ReactDOM.version`
* Add `ReactDOMServer.version`
Expand Down