Skip to content

Commit 30e228d

Browse files
committed
fix: set property of immutable object
1 parent ca16dc4 commit 30e228d

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

crates/jsshaker/src/entity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'a> Entity<'a> {
178178
) -> Option<(Dep<'a>, ObjectPrototype<'a>, ObjectPrototype<'a>)> {
179179
self.value.get_constructor_prototype(analyzer, self.forward_dep(dep, analyzer))
180180
}
181-
pub fn get_object(&self) -> Option<&'a ObjectValue<'a>> {
181+
pub fn as_object(&self) -> Option<&'a ObjectValue<'a>> {
182182
self.value.as_object()
183183
}
184184
pub fn test_typeof(&self) -> TypeofResult {

crates/jsshaker/src/value/function/call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a> FunctionValue<'a> {
113113
include: bool,
114114
) -> Entity<'a> {
115115
let prototype = self.get_prototype(analyzer, dep);
116-
let target = if let Some(p) = prototype.get_object() {
116+
let target = if let Some(p) = prototype.as_object() {
117117
let target = analyzer.new_empty_object(ObjectPrototype::Custom(p), p.mangling_group.get());
118118
target.add_extra_dep(prototype.get_shallow_dep(analyzer));
119119
target

crates/jsshaker/src/value/function/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a> ValueTrait<'a> for FunctionValue<'a> {
186186
Some((
187187
dep,
188188
ObjectPrototype::Custom(self.statics),
189-
if let Some(prototype) = prototype.get_object() {
189+
if let Some(prototype) = prototype.as_object() {
190190
ObjectPrototype::Custom(prototype)
191191
} else {
192192
ObjectPrototype::Unknown(analyzer.factory.dep(prototype))

crates/jsshaker/src/value/logical_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a> ValueTrait<'a> for LogicalResultValue<'a> {
132132
}
133133

134134
fn as_object(&'a self) -> Option<&'a ObjectValue<'a>> {
135-
self.value.get_object()
135+
self.value.as_object()
136136
}
137137

138138
fn test_typeof(&self) -> TypeofResult {

crates/jsshaker/src/value/object/set.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ impl<'a> ObjectValue<'a> {
2424
value: Entity<'a>,
2525
) {
2626
if self.immutable {
27-
return;
27+
return escaped::set_property(analyzer, dep, key, value);
2828
}
2929

3030
if self.is_self_or_proto_included() {
31+
analyzer.include(self);
3132
return escaped::set_property(analyzer, dep, key, value);
3233
}
3334

0 commit comments

Comments
 (0)