Skip to content

Commit

Permalink
fix(core/webidl): pad static methods
Browse files Browse the repository at this point in the history
* closes #1559
  • Loading branch information
marcoscaceres committed Mar 10, 2018
1 parent ec12659 commit d47417a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/core/webidl.js
Expand Up @@ -586,11 +586,16 @@ function writeInterfaceDefinition(opt, fixes = {}) {
var len = idlType2Text(it.idlType).length;
if (it.type === "attribute") {
var qualifiersLen = writeAttributeQualifiers(it).length;
maxAttr = len > maxAttr ? len : maxAttr;
maxAttrQualifiers =
qualifiersLen > maxAttrQualifiers ? qualifiersLen : maxAttrQualifiers;
} else if (it.type === "operation") maxMeth = len > maxMeth ? len : maxMeth;
else if (it.type === "const") maxConst = len > maxConst ? len : maxConst;
maxAttr = Math.max(len, maxAttr);
maxAttrQualifiers = Math.max(qualifiersLen, maxAttrQualifiers);
} else if (it.type === "operation") {
if (it.static) {
len += "static ".length;
}
maxMeth = Math.max(len, maxMeth);
} else if (it.type === "const") {
maxConst = Math.max(len, maxConst);
}
}
var children = obj.members
.map(function(ch) {
Expand Down Expand Up @@ -672,13 +677,11 @@ function writeMethod(meth, max, indent) {
});
var params = paramObjs.join(", ");
var len = idlType2Text(meth.idlType).length;
if (meth.static) len += 7;
var specialProps = [
"getter",
"setter",
"deleter",
"legacycaller",
"stringifier",
"static", // not "special op", but serves same role
];
var special = "";
for (var i in specialProps) {
Expand All @@ -692,7 +695,6 @@ function writeMethod(meth, max, indent) {
var methObj = {
obj: meth,
indent: indent,
static: meth.static ? "static " : "",
special: special,
pad: pad,
children: params,
Expand Down

0 comments on commit d47417a

Please sign in to comment.