@@ -26,6 +26,7 @@ using v8::Object;
26
26
using v8::PropertyAttribute;
27
27
using v8::ReadOnly;
28
28
using v8::RegExp;
29
+ using v8::Signature;
29
30
using v8::String;
30
31
using v8::Value;
31
32
@@ -720,58 +721,71 @@ static void Initialize(Local<Object> target,
720
721
auto prototype_template = ctor_tmpl->PrototypeTemplate ();
721
722
ctor_tmpl->SetClassName (FIXED_ONE_BYTE_STRING (isolate, " URLPattern" ));
722
723
724
+ // The signature is used to prevent the property accessors from being
725
+ // called on the wrong receiver object (`this`)
726
+ auto signature = Signature::New (isolate, ctor_tmpl);
727
+
723
728
instance_template->SetInternalFieldCount (URLPattern::kInternalFieldCount );
724
729
prototype_template->SetAccessorProperty (
725
730
env->protocol_string (),
726
- FunctionTemplate::New (isolate, URLPattern::Protocol),
731
+ FunctionTemplate::New (
732
+ isolate, URLPattern::Protocol, Local<Value>(), signature),
727
733
Local<FunctionTemplate>(),
728
734
attributes);
729
735
730
736
prototype_template->SetAccessorProperty (
731
737
env->username_string (),
732
- FunctionTemplate::New (isolate, URLPattern::Username),
738
+ FunctionTemplate::New (
739
+ isolate, URLPattern::Username, Local<Value>(), signature),
733
740
Local<FunctionTemplate>(),
734
741
attributes);
735
742
736
743
prototype_template->SetAccessorProperty (
737
744
env->password_string (),
738
- FunctionTemplate::New (isolate, URLPattern::Password),
745
+ FunctionTemplate::New (
746
+ isolate, URLPattern::Password, Local<Value>(), signature),
739
747
Local<FunctionTemplate>(),
740
748
attributes);
741
749
742
750
prototype_template->SetAccessorProperty (
743
751
env->hostname_string (),
744
- FunctionTemplate::New (isolate, URLPattern::Hostname),
752
+ FunctionTemplate::New (
753
+ isolate, URLPattern::Hostname, Local<Value>(), signature),
745
754
Local<FunctionTemplate>(),
746
755
attributes);
747
756
748
757
prototype_template->SetAccessorProperty (
749
758
env->port_string (),
750
- FunctionTemplate::New (isolate, URLPattern::Port),
759
+ FunctionTemplate::New (
760
+ isolate, URLPattern::Port, Local<Value>(), signature),
751
761
Local<FunctionTemplate>(),
752
762
attributes);
753
763
754
764
prototype_template->SetAccessorProperty (
755
765
env->pathname_string (),
756
- FunctionTemplate::New (isolate, URLPattern::Pathname),
766
+ FunctionTemplate::New (
767
+ isolate, URLPattern::Pathname, Local<Value>(), signature),
757
768
Local<FunctionTemplate>(),
758
769
attributes);
759
770
760
771
prototype_template->SetAccessorProperty (
761
772
env->search_string (),
762
- FunctionTemplate::New (isolate, URLPattern::Search),
773
+ FunctionTemplate::New (
774
+ isolate, URLPattern::Search, Local<Value>(), signature),
763
775
Local<FunctionTemplate>(),
764
776
attributes);
765
777
766
778
prototype_template->SetAccessorProperty (
767
779
env->hash_string (),
768
- FunctionTemplate::New (isolate, URLPattern::Hash),
780
+ FunctionTemplate::New (
781
+ isolate, URLPattern::Hash, Local<Value>(), signature),
769
782
Local<FunctionTemplate>(),
770
783
attributes);
771
784
772
785
prototype_template->SetAccessorProperty (
773
786
env->has_regexp_groups_string (),
774
- FunctionTemplate::New (isolate, URLPattern::HasRegexpGroups),
787
+ FunctionTemplate::New (
788
+ isolate, URLPattern::HasRegexpGroups, Local<Value>(), signature),
775
789
Local<FunctionTemplate>(),
776
790
attributes);
777
791
0 commit comments