(options, spec)
| 38 | // Given a mode spec (anything that resolveMode accepts), find and |
| 39 | // initialize an actual mode object. |
| 40 | export function getMode(options, spec) { |
| 41 | spec = resolveMode(spec) |
| 42 | let mfactory = modes[spec.name] |
| 43 | if (!mfactory) return getMode(options, "text/plain") |
| 44 | let modeObj = mfactory(options, spec) |
| 45 | if (modeExtensions.hasOwnProperty(spec.name)) { |
| 46 | let exts = modeExtensions[spec.name] |
| 47 | for (let prop in exts) { |
| 48 | if (!exts.hasOwnProperty(prop)) continue |
| 49 | if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop] |
| 50 | modeObj[prop] = exts[prop] |
| 51 | } |
| 52 | } |
| 53 | modeObj.name = spec.name |
| 54 | if (spec.helperType) modeObj.helperType = spec.helperType |
| 55 | if (spec.modeProps) for (let prop in spec.modeProps) |
| 56 | modeObj[prop] = spec.modeProps[prop] |
| 57 | |
| 58 | return modeObj |
| 59 | } |
| 60 | |
| 61 | // This can be used to attach properties to mode objects from |
| 62 | // outside the actual mode definition. |
no test coverage detected