( js: NodeCompiler, node: Optional.Node.withDefault, out: string, isPlain = false )
| 1786 | : `Object.getPrototypeOf(${target}) === Object.prototype ? (${target}${js.prop(key)} = ${value}) : ${js.ref(setOwnValue)}(${target}, ${js.serialize(key)}, ${value})` |
| 1787 | |
| 1788 | export const compileDefault = ( |
| 1789 | js: NodeCompiler, |
| 1790 | node: Optional.Node.withDefault, |
| 1791 | out: string, |
| 1792 | isPlain = false |
| 1793 | ): NodeCompiler => { |
| 1794 | if (hasPlainDefault(node)) { |
| 1795 | return js.line( |
| 1796 | jsSetOwnProp( |
| 1797 | js, |
| 1798 | out, |
| 1799 | node.key, |
| 1800 | serializeDefault(js, node.default), |
| 1801 | isPlain |
| 1802 | ) |
| 1803 | ) |
| 1804 | } |
| 1805 | return compileDefaultMorph( |
| 1806 | js, |
| 1807 | node, |
| 1808 | `${js.ref(node.defMorph)}(${out}${node.defMorph.length === 2 ? ", ctx" : ""})`, |
| 1809 | out |
| 1810 | ) |
| 1811 | } |
| 1812 | |
| 1813 | // one compileDefault writes as a value, calling nothing |
| 1814 | const hasPlainDefault = (node: Prop.Node): boolean => |
no test coverage detected