data/pandoc.lua: fix Element inheritance
Extending all elements of a given type (e.g., all inline elements) was
difficult, as the table used to lookup unknown methods would be reset
every time a new element of that type was created, preventing recursive
property lookup. This is was changed in that all methods and attributes
of supertypes are now available to their subtypes.
commitf492f5a6dd991530241529d1110e73260d3a1d43
authorAlbert Krewinkel <albert@zeitkraut.de>
dateSat 6 Jan 2018, 23:25 (9 years ago)
parent3a22907
data/pandoc.lua+3−2
@@ -33,13 +33,15 @@ local List = require 'pandoc.List'
3333-- @type Element
3434-- @local
3535local Element = {}
36+Element.__index = Element
3637
3738--- Create a new element subtype
3839-- @local
3940function Element:make_subtype(o)
4041 o = o or {}
4142 setmetatable(o, self)
42− self.__index = self
43+ -- Make subtype usable as a metatable
44+ o.__index = o
4345 return o
4446end
4547
@@ -57,7 +59,6 @@ function Element:new(tag, ...)
5759 element.c = content
5860 end
5961 setmetatable(element, self)
60− self.__index = self
6162 return element
6263end
6364