From fc0f18c80902315c0cce5766ae77b42df0ce2ecd Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Fri, 14 Jan 2022 20:49:09 +0100 Subject: [PATCH] fix: only warn once about WeakRef.clear() deprecation. (#140) --- NativeScript/runtime/WeakRef.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NativeScript/runtime/WeakRef.cpp b/NativeScript/runtime/WeakRef.cpp index d9601338..adff449f 100644 --- a/NativeScript/runtime/WeakRef.cpp +++ b/NativeScript/runtime/WeakRef.cpp @@ -9,8 +9,13 @@ void WeakRef::Init(Local 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.'); } )";