Skip to content

Commit

Permalink
fix: remove IIFE for compatibility issues, see #9
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Nov 5, 2019
1 parent 60e9ab1 commit b3707c2
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/target-php/compilers/element-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,24 @@ export class ElementCompiler {
}

if (bindDirective) {
emitter.nextLine('(')
emitter.writeAnonymousFunction(['$bindObj'], ['&$html'], () => {
emitter.writeForeach('$bindObj as $key => $value', () => {
if (tagName === 'textarea') {
emitter.writeIf('$key == "value"', () => emitter.writeContinue())
}
emitter.nextLine(`$bindObj = ${compileExprSource.expr(bindDirective.value)};`)
emitter.writeForeach('$bindObj as $key => $value', () => {
if (tagName === 'textarea') {
emitter.writeIf('$key == "value"', () => emitter.writeContinue())
}

emitter.writeSwitch('$key', () => {
emitter.writeCase('"readonly"')
emitter.writeCase('"disabled"')
emitter.writeCase('"multiple"', () => {
emitter.writeLine('$html .= _::boolAttrFilter($key, _::escapeHTML($value));')
emitter.writeBreak()
})
emitter.writeDefault(() => {
emitter.writeLine('$html .= _::attrFilter($key, _::escapeHTML($value));')
})
emitter.writeSwitch('$key', () => {
emitter.writeCase('"readonly"')
emitter.writeCase('"disabled"')
emitter.writeCase('"multiple"', () => {
emitter.writeLine('$html .= _::boolAttrFilter($key, _::escapeHTML($value));')
emitter.writeBreak()
})
emitter.writeDefault(() => {
emitter.writeLine('$html .= _::attrFilter($key, _::escapeHTML($value));')
})
})
})

emitter.write(')(')
emitter.write(compileExprSource.expr(bindDirective.value))
emitter.feedLine(');')
}

emitter.bufferHTMLLiteral('>')
Expand Down

0 comments on commit b3707c2

Please sign in to comment.