Comparison

core/moduleapi.lua @ 12479:4d36fbcdd210 0.12

core.moduleapi: Fix 'global' property via :context() - #1748 The 'global' property should reflect whether the module API instance represents the global context or a VirtualHost or Component context. However the module:context() method did not override this, leading the property of the previous module shining trough, leading to bugs in code relying on the 'global' property. See also #1736
author Kim Alvefur <zash@zash.se>
date Wed, 27 Apr 2022 17:18:46 +0200
parent 12253:57d35fcde488
child 12589:39ae08180c81
comparison
equal deleted inserted replaced
12477:cc84682b8429 12479:4d36fbcdd210
305 return resolve_relative_path(parent, value); 305 return resolve_relative_path(parent, value);
306 end 306 end
307 307
308 308
309 function api:context(host) 309 function api:context(host)
310 return setmetatable({host=host or "*"}, {__index=self,__newindex=self}); 310 return setmetatable({ host = host or "*", global = "*" == host }, { __index = self, __newindex = self });
311 end 311 end
312 312
313 function api:add_item(key, value) 313 function api:add_item(key, value)
314 self.items = self.items or {}; 314 self.items = self.items or {};
315 self.items[key] = self.items[key] or {}; 315 self.items[key] = self.items[key] or {};