If .startsWith (or any other method) is used on a clojurescript string object when using :optimizarions :advanced code does not work

Description

This is a minimal project HelloWorld (I am attaching a full project "minimal.tgz"):
(ns minimal.core)

(let [elem (.getElementById js/document "app")]
(set! (.-innerHTML elem) (str "Hello World " (.. "Hello" (startsWith "H")))))

Will run fine with no optimizarions but when using :advanced I get: Uncaught TypeError: "Hello".Lb is not a function

Environment

MAC OS

Activity

Show:
David Nolen
August 31, 2015, 9:31 PM

This is not a bug. That's how Closure advanced optimization works. Use goog.string/startsWith instead.

Rohit Aggarwal
September 1, 2015, 11:37 AM

I think that the issue is that Closure compiler may not be including ES2015 externs yet. `.startsWith` has been added to String prototype in ES2015. So I would have imagined that if the extern was provided, it shouldn't have mangled the function name.

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Affects versions

Priority

Major
Configure