Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
93dfa4b1
Unverified
Commit
93dfa4b1
authored
Jul 10, 2020
by
Kyle Keating
Committed by
GitHub
Jul 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve typechecking in several shared modules (#2323)
parent
9fab053b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
dom-element.js
src/shared/dom-element.js
+3
-0
frame-rpc.js
src/shared/frame-rpc.js
+14
-0
type-coercions.js
src/shared/type-coercions.js
+1
-1
No files found.
src/shared/dom-element.js
View file @
93dfa4b1
...
...
@@ -7,6 +7,9 @@
/**
* Implementation of `element.closest(selector)`. This is used to support browsers
* (IE 11) that don't have a native implementation.
*
* @param {Element|null} element
* @param {string} selector
*/
export
function
closest
(
element
,
selector
)
{
while
(
element
)
{
...
...
src/shared/frame-rpc.js
View file @
93dfa4b1
...
...
@@ -29,6 +29,13 @@
const
VERSION
=
'1.0.0'
;
/**
* @constructor
* @param {Window} src
* @param {Window} dst
* @param {string} origin
* @param {(Object<string, ((any) => any)>) | ((any) => any)} methods
*/
export
default
function
RPC
(
src
,
dst
,
origin
,
methods
)
{
if
(
!
(
this
instanceof
RPC
))
return
new
RPC
(
src
,
dst
,
origin
,
methods
);
const
self
=
this
;
...
...
@@ -64,11 +71,18 @@ RPC.prototype.destroy = function () {
this
.
src
.
removeEventListener
(
'message'
,
this
.
_onmessage
);
};
/**
* @param {string} method
*/
RPC
.
prototype
.
call
=
function
(
method
)
{
const
args
=
[].
slice
.
call
(
arguments
,
1
);
return
this
.
apply
(
method
,
args
);
};
/**
* @param {string} method
* @param {any[]} args
*/
RPC
.
prototype
.
apply
=
function
(
method
,
args
)
{
if
(
this
.
_destroyed
)
return
;
const
seq
=
this
.
_sequence
++
;
...
...
src/shared/type-coercions.js
View file @
93dfa4b1
...
...
@@ -44,7 +44,7 @@ export function toInteger(value) {
* Returns either the value if its an object or an empty object
*
* @param {any} value - initial value
* @return {
o
bject}
* @return {
O
bject}
*/
export
function
toObject
(
value
)
{
if
(
typeof
value
===
'object'
&&
value
!==
null
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment