From b3ec54259fa27d1684836e4264a519c4744c165b Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 11 Jan 2022 16:52:50 +0100 Subject: [PATCH] feat: only warn once about WeakRef.clear() deprecation. --- 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.'); } )";