2017-02-02 18 views

답변

1

가장 간단한 해결책은 API를 spec'ed 이름으로 polyfill하여 공급 업체 접두사 버전으로 리디렉션하는 것입니다. 예를 들어, 자바 스크립트 파일 : Scala.js에서

if (!Document.prototype.hasOwnProperty("fullscreenEnabled")) { 
    if (Document.prototype.hasOwnProperty("webkitFullscreenEnabled")) 
    Object.defineProperty(Document.prototype, "fullscreenEnabled", { 
     get: function() { return this.webkitFullscreenEnabled; } 
    } 
    } 
} 

또는 :

import scala.scalajs.js 
import js.DynamicImplicits._ 
import js.Dynamic.{global => g} 

if (!g.Document.prototype.hasOwnProperty("fullscreenEnabled")) { 
    if (g.Document.prototype.hasOwnProperty("webkitFullscreenEnabled")) 
    js.Object.defineProperty(g.Document.prototype, "fullscreenEnabled", js.Dynamic.literal(
     get = { (thiz: js.Dynamic) => thiz.webkitFullscreenEnabled; }: js.ThisFunction 
    ) 
    } 
} 
+0

니스. 이벤트 핸들러를 polyfill 할 수 있습니까? 'onwebkitfullscreenerror'에서'onfullscreenerror'에 등록 된 핸들러가 트리거되도록하려면 어떻게해야합니까? – Suma

+0

흠, 잘 모르겠다. 웹 커뮤니티 전체에 대해 더 나은 행운을 누릴 수 있습니다. – sjrd