Skip to content

Commit fc0f18c

Browse files
rigor789NathanWalker
authored andcommitted
fix: only warn once about WeakRef.clear() deprecation. (#140)
1 parent b773d0b commit fc0f18c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

NativeScript/runtime/WeakRef.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ void WeakRef::Init(Local<Context> context) {
99
Isolate* isolate = context->GetIsolate();
1010

1111
std::string source = R"(
12-
global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
12+
global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
13+
global.WeakRef.prototype.__hasWarnedAboutClear = false;
1314
global.WeakRef.prototype.clear = () => {
15+
if(global.WeakRef.prototype.__hasWarnedAboutClear) {
16+
return;
17+
}
18+
global.WeakRef.prototype.__hasWarnedAboutClear = true;
1419
console.warn('WeakRef.clear() is non-standard and has been deprecated. It does nothing and the call can be safely removed.');
1520
}
1621
)";

0 commit comments

Comments
 (0)