github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/custom_elements.go (about) 1 // Copyright (c) 2016 Paul Jolly <paul@myitcv.org.uk>, all rights reserved. 2 // Use of this document is governed by a license found in the LICENSE document. 3 4 package react 5 6 import "github.com/gopherjs/gopherjs/js" 7 8 // DangerousInnerHTML is convenience definition that allows HTML to be directly 9 // set as the child of a DOM element. See 10 // https://facebook.github.io/react/docs/dom-elements.html#dangerouslysetinnerhtml 11 // for more details 12 type DangerousInnerHTML struct { 13 o *js.Object 14 } 15 16 // NewDangerousInnerHTML creates a new DangerousInnerHTML instance, using the 17 // supplied string as the raw HTML 18 func NewDangerousInnerHTML(s string) *DangerousInnerHTML { 19 o := object.New() 20 o.Set("__html", s) 21 22 res := &DangerousInnerHTML{o: o} 23 24 return res 25 } 26 27 func (d *DangerousInnerHTML) reactElement() {} 28 29 // FragmentElem is the special React Fragment element definition. Fragments let 30 // you group a list of children without adding extra nodes to the DOM. See 31 // https://reactjs.org/docs/fragments.html for more details. 32 type FragmentElem struct { 33 Element 34 } 35 36 // Fragment creates a new instance of a <React.Fragment> element with the 37 // provided children 38 func Fragment(children ...Element) *FragmentElem { 39 return &FragmentElem{ 40 Element: createElement(symbolFragment, nil, children...), 41 } 42 }