Skip to content

Commit

Permalink
fix: only warn once about WeakRef.clear() deprecation. (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 authored Jan 14, 2022
1 parent 9a39108 commit 7fd4a31
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion NativeScript/runtime/WeakRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ void WeakRef::Init(Local<Context> context) {
Isolate* isolate = context->GetIsolate();

std::string source = R"(
global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
global.WeakRef.prototype.__hasWarnedAboutClear = false;
global.WeakRef.prototype.clear = () => {
if(global.WeakRef.prototype.__hasWarnedAboutClear) {
return;
}
global.WeakRef.prototype.__hasWarnedAboutClear = true;
console.warn('WeakRef.clear() is non-standard and has been deprecated. It does nothing and the call can be safely removed.');
}
)";
Expand Down

0 comments on commit 7fd4a31

Please sign in to comment.